debug streaming

Signed-off-by: José Ulises Niño Rivera <junr03@users.noreply.github.com>
This commit is contained in:
José Ulises Niño Rivera 2024-10-13 15:36:53 -06:00
parent 639839fbb1
commit bbd6058ca0
5 changed files with 122 additions and 230 deletions

View file

@ -4,13 +4,11 @@ import os
from openai import OpenAI
import gradio as gr
api_key = os.getenv("OPENAI_API_KEY")
CHAT_COMPLETION_ENDPOINT = os.getenv(
"CHAT_COMPLETION_ENDPOINT", "https://api.openai.com/v1"
)
client = OpenAI(api_key=api_key, base_url=CHAT_COMPLETION_ENDPOINT)
client = OpenAI(api_key="--", base_url=CHAT_COMPLETION_ENDPOINT)
def predict(message, history):
history_openai_format = []
@ -20,7 +18,7 @@ def predict(message, history):
history_openai_format.append({"role": "user", "content": message})
response = client.chat.completions.create(
model="gpt-3.5-turbo",
model="arch",
messages=history_openai_format,
temperature=1.0,
stream=True,
@ -33,4 +31,4 @@ def predict(message, history):
yield partial_message
gr.ChatInterface(predict).launch(server_name="0.0.0.0", server_port=8081)
gr.ChatInterface(predict).launch(server_name="0.0.0.0", server_port=8080)