Commit
路
37ff396
1
Parent(s):
b62c322
Refactor call_nvidia_api and chat functions
Browse files
app.py
CHANGED
@@ -26,16 +26,14 @@ def user(message, history):
|
|
26 |
history = history or []
|
27 |
history.append({"role": "user", "content": message})
|
28 |
return history
|
29 |
-
def call_nvidia_api(history):
|
30 |
-
# Preparar o payload com o hist贸rico de chat formatado
|
31 |
payload = {
|
32 |
"messages": history,
|
33 |
-
"temperature":
|
34 |
-
"top_p":
|
35 |
-
"max_tokens":
|
36 |
-
"
|
37 |
-
|
38 |
-
}
|
39 |
|
40 |
session = requests.Session()
|
41 |
response = session.post(INVOKE_URL, headers=headers, json=payload)
|
@@ -55,11 +53,11 @@ def call_nvidia_api(history):
|
|
55 |
|
56 |
return history
|
57 |
|
58 |
-
def chat(history, system_message):
|
59 |
print("Starting chat...")
|
60 |
-
|
61 |
-
updated_history = call_nvidia_api(history)
|
62 |
return updated_history, ""
|
|
|
63 |
# Gradio interface setup
|
64 |
with gr.Blocks() as demo:
|
65 |
with gr.Row():
|
|
|
26 |
history = history or []
|
27 |
history.append({"role": "user", "content": message})
|
28 |
return history
|
29 |
+
def call_nvidia_api(history, max_tokens, temperature, top_p):
|
|
|
30 |
payload = {
|
31 |
"messages": history,
|
32 |
+
"temperature": temperature,
|
33 |
+
"top_p": top_p,
|
34 |
+
"max_tokens": max_tokens,
|
35 |
+
"stream": False
|
36 |
+
}
|
|
|
37 |
|
38 |
session = requests.Session()
|
39 |
response = session.post(INVOKE_URL, headers=headers, json=payload)
|
|
|
53 |
|
54 |
return history
|
55 |
|
56 |
+
def chat(history, system_message, max_tokens, temperature, top_p, top_k, repetition_penalty):
|
57 |
print("Starting chat...")
|
58 |
+
updated_history = call_nvidia_api(history, max_tokens, temperature, top_p)
|
|
|
59 |
return updated_history, ""
|
60 |
+
|
61 |
# Gradio interface setup
|
62 |
with gr.Blocks() as demo:
|
63 |
with gr.Row():
|