Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,10 +2,11 @@ import gradio as gr
|
|
| 2 |
from share_btn import community_icon_html, loading_icon_html, share_js
|
| 3 |
import re
|
| 4 |
import os
|
| 5 |
-
hf_token = os.environ.get('HF_TOKEN')
|
|
|
|
|
|
|
| 6 |
from gradio_client import Client
|
| 7 |
-
client = Client("https://fffiloni-test-llama-api-debug.hf.space/", hf_token=hf_token)
|
| 8 |
-
|
| 9 |
clipi_client = Client("https://fffiloni-clip-interrogator-2.hf.space/")
|
| 10 |
|
| 11 |
def get_text_after_colon(input_text):
|
|
@@ -39,12 +40,14 @@ def infer(image_input, audience):
|
|
| 39 |
|
| 40 |
"""
|
| 41 |
gr.Info('Calling Llama2 ...')
|
| 42 |
-
result = client.predict(
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
)
|
| 47 |
-
|
|
|
|
|
|
|
| 48 |
print(f"Llama2 result: {result}")
|
| 49 |
|
| 50 |
result = get_text_after_colon(result)
|
|
|
|
| 2 |
from share_btn import community_icon_html, loading_icon_html, share_js
|
| 3 |
import re
|
| 4 |
import os
|
| 5 |
+
#hf_token = os.environ.get('HF_TOKEN')
|
| 6 |
+
import openai
|
| 7 |
+
OPENAI_API_KEY = os.environ.get('OPENAI_API_KEY')
|
| 8 |
from gradio_client import Client
|
| 9 |
+
#client = Client("https://fffiloni-test-llama-api-debug.hf.space/", hf_token=hf_token)
|
|
|
|
| 10 |
clipi_client = Client("https://fffiloni-clip-interrogator-2.hf.space/")
|
| 11 |
|
| 12 |
def get_text_after_colon(input_text):
|
|
|
|
| 40 |
|
| 41 |
"""
|
| 42 |
gr.Info('Calling Llama2 ...')
|
| 43 |
+
#result = client.predict(
|
| 44 |
+
# llama_q, # str in 'Message' Textbox component
|
| 45 |
+
# "I2S",
|
| 46 |
+
# api_name="/predict"
|
| 47 |
+
#)
|
| 48 |
+
chat_completion = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=[{"role": "user", "content": llama_q}])
|
| 49 |
+
result = chat_completion.choices[0].message.content
|
| 50 |
+
|
| 51 |
print(f"Llama2 result: {result}")
|
| 52 |
|
| 53 |
result = get_text_after_colon(result)
|