Lakpa Sherpa
commited on
Commit
·
6f1daf1
1
Parent(s):
f31e4ac
configured to use local model.
Browse files
app.py
CHANGED
|
@@ -7,12 +7,35 @@ import os
|
|
| 7 |
import openai
|
| 8 |
import requests
|
| 9 |
import json
|
| 10 |
-
|
| 11 |
openai.organization = "org-5Z0c3Uk1VG7t3TsczN6M4FCi"
|
| 12 |
#openai.api_key = os.getenv("OPENAI_API_KEY")
|
| 13 |
openai.api_key_path ="./key.txt"
|
| 14 |
|
| 15 |
def askGPT(prompt="what can I make with potato?"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
response = openai.ChatCompletion.create(
|
| 17 |
model="gpt-3.5-turbo",
|
| 18 |
messages=[
|
|
@@ -31,7 +54,7 @@ def askGPT(prompt="what can I make with potato?"):
|
|
| 31 |
presence_penalty=0
|
| 32 |
)
|
| 33 |
result = response["choices"][0]["message"]["content"]
|
| 34 |
-
return result
|
| 35 |
|
| 36 |
def classifyImage(image):
|
| 37 |
pipe = pipeline("image-classification", model="microsoft/resnet-50")
|
|
|
|
| 7 |
import openai
|
| 8 |
import requests
|
| 9 |
import json
|
| 10 |
+
from openai import OpenAI
|
| 11 |
openai.organization = "org-5Z0c3Uk1VG7t3TsczN6M4FCi"
|
| 12 |
#openai.api_key = os.getenv("OPENAI_API_KEY")
|
| 13 |
openai.api_key_path ="./key.txt"
|
| 14 |
|
| 15 |
def askGPT(prompt="what can I make with potato?"):
|
| 16 |
+
|
| 17 |
+
client = OpenAI(
|
| 18 |
+
base_url='http://localhost:11434/v1/',
|
| 19 |
+
|
| 20 |
+
# required but ignored
|
| 21 |
+
api_key='ollama',
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
chat_completion = client.chat.completions.create(
|
| 25 |
+
messages=[
|
| 26 |
+
{
|
| 27 |
+
'role': 'user',
|
| 28 |
+
'content': prompt,
|
| 29 |
+
}
|
| 30 |
+
],
|
| 31 |
+
model='llama3',
|
| 32 |
+
)
|
| 33 |
+
|
| 34 |
+
result = chat_completion.choices[0].message.content
|
| 35 |
+
#print(chat_completion.choices[0].message.content)
|
| 36 |
+
return result
|
| 37 |
+
|
| 38 |
+
'''def askGPT(prompt="what can I make with potato?"):
|
| 39 |
response = openai.ChatCompletion.create(
|
| 40 |
model="gpt-3.5-turbo",
|
| 41 |
messages=[
|
|
|
|
| 54 |
presence_penalty=0
|
| 55 |
)
|
| 56 |
result = response["choices"][0]["message"]["content"]
|
| 57 |
+
return result'''
|
| 58 |
|
| 59 |
def classifyImage(image):
|
| 60 |
pipe = pipeline("image-classification", model="microsoft/resnet-50")
|