piątek, grudnia 29, 2023

Mistral czeka na książkę

Bawię się Mistral'em, to taki nowy LLMowy model, który działa całkiem szybko nawet na Macbooku Air z 2020 roku.

I podpiąłem go dziś do mojego detektora kolejnej książki ze świata Bobiverse... i drań jak czytał:


To uznawał z moim promptem (który działa z ChatGPT), że książka jest jak najbardziej dostępna...

Prompt wyglądał tak:

I have a status update snippet from an author's page. From this snippet, I need to know:Whether the book mentioned is currently available for purchase.The exact title of the book.Any hint or specific date mentioned for the book's release.Please provide the answers in JSON format like: {{ "bookAvailable": true/false, "bookTitle": "Title Here", "bookReleaseDate": "Date or Hint Here" }}.Here's the snippet: {item}

Dawał odpowiedź, że tak książka jest dostępna i nazywa się The Bobiverse i release date to styczeń albo luty 2024....

Dopiero gdy zmieniłem go na:

Read status update snippet from an author's page. From this snippet, answer questions:Whether the book as ebook not audiobook mentioned is currently available for purchase.Where this book as ebook not audiobook is available for purchase.The exact title of the book.Any hint or specific date mentioned for the book's release.Please provide the answers in JSON format like: {{ "bookAvailable": true/false, "whereToBuy": "information where as ebook not audiobook may be purchased", "bookTitle": "Title Here", "bookReleaseDate": "Date or Hint Here" }}. Here's the snippet: {item}

W którym jak widać dodałem informacje, że chodzi o dostępność jako ebook, a nie audiobook to zaczął działać w miarę znośnie ;-)

Mój "moduł" mistral.py wygląda tak:

import urllib
import urllib.request
import json

def talkToModel(query,model="mistral"):
data = {
"model": model,
"prompt": query
}
url="http://localhost:11434/api/generate"
json_data = json.dumps(data).encode('utf-8')
print(json_data)
req = urllib.request.Request(url, data=json_data, headers={'content-type': 'application/json'})
response = urllib.request.urlopen(req)
result=response.read()
lines=result.decode("utf-8").strip().split("\n")
content="".join([json.loads(x)["response"] if len(x)>0 else "" for x in lines])
return content




Podobne postybeta
GPT + Python = sprawdzanie czy 5 książka z Bobiverse już jest dostępna ;-)
Żenienie Todoist z Obsidian przy pomocy Pythona ;-)
Kiedy skończyć pracę...
Search it later ;-)
Jak nie zapomnieć kupić biletu miesięcznego - revised ;-)

Brak komentarzy:

Prześlij komentarz