Spaces:
Runtime error
Runtime error
academy04 commited on
Commit ·
ee7a0fe
1
Parent(s): fcf1b5b
fix model,remove stream
Browse files- __pycache__/app.cpython-38.pyc +0 -0
- app.py +15 -32
- requirements.txt +0 -2
__pycache__/app.cpython-38.pyc
ADDED
|
Binary file (1.03 kB). View file
|
|
|
app.py
CHANGED
|
@@ -10,24 +10,10 @@ client = OpenAI(
|
|
| 10 |
def respond(
|
| 11 |
message,
|
| 12 |
history: list[tuple[str, str]],
|
| 13 |
-
system_message,
|
| 14 |
-
max_tokens,
|
| 15 |
-
temperature,
|
| 16 |
-
top_p,
|
| 17 |
):
|
| 18 |
-
messages = [{"role": "system", "content": system_message}]
|
| 19 |
-
|
| 20 |
-
for val in history:
|
| 21 |
-
if val[0]:
|
| 22 |
-
messages.append({"role": "user", "content": val[0]})
|
| 23 |
-
if val[1]:
|
| 24 |
-
messages.append({"role": "assistant", "content": val[1]})
|
| 25 |
-
|
| 26 |
-
messages.append({"role": "user", "content": message})
|
| 27 |
-
|
| 28 |
response = ""
|
| 29 |
|
| 30 |
-
|
| 31 |
extra_body={},
|
| 32 |
model="openrouter/optimus-alpha",
|
| 33 |
messages=[
|
|
@@ -41,11 +27,8 @@ def respond(
|
|
| 41 |
]
|
| 42 |
}
|
| 43 |
]
|
| 44 |
-
)
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
response += token
|
| 48 |
-
yield response
|
| 49 |
|
| 50 |
|
| 51 |
"""
|
|
@@ -53,18 +36,18 @@ For information on how to customize the ChatInterface, peruse the gradio docs: h
|
|
| 53 |
"""
|
| 54 |
demo = gr.ChatInterface(
|
| 55 |
respond,
|
| 56 |
-
additional_inputs=[
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
],
|
| 68 |
)
|
| 69 |
|
| 70 |
|
|
|
|
| 10 |
def respond(
|
| 11 |
message,
|
| 12 |
history: list[tuple[str, str]],
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
response = ""
|
| 15 |
|
| 16 |
+
response = client.chat.completions.create(
|
| 17 |
extra_body={},
|
| 18 |
model="openrouter/optimus-alpha",
|
| 19 |
messages=[
|
|
|
|
| 27 |
]
|
| 28 |
}
|
| 29 |
]
|
| 30 |
+
).choices[0].message.content
|
| 31 |
+
return response
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
|
| 34 |
"""
|
|
|
|
| 36 |
"""
|
| 37 |
demo = gr.ChatInterface(
|
| 38 |
respond,
|
| 39 |
+
# additional_inputs=[
|
| 40 |
+
# gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
|
| 41 |
+
# gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
| 42 |
+
# gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
| 43 |
+
# gr.Slider(
|
| 44 |
+
# minimum=0.1,
|
| 45 |
+
# maximum=1.0,
|
| 46 |
+
# value=0.95,
|
| 47 |
+
# step=0.05,
|
| 48 |
+
# label="Top-p (nucleus sampling)",
|
| 49 |
+
# ),
|
| 50 |
+
# ],
|
| 51 |
)
|
| 52 |
|
| 53 |
|
requirements.txt
CHANGED
|
@@ -1,3 +1 @@
|
|
| 1 |
-
huggingface_hub==0.25.2
|
| 2 |
-
google-genai
|
| 3 |
openai
|
|
|
|
|
|
|
|
|
|
| 1 |
openai
|