Spaces:
Runtime error
Runtime error
update button width
Browse files
app.py
CHANGED
@@ -28,7 +28,7 @@ def predict_chatgpt(inputs, top_p_chatgpt, temperature_chatgpt, openai_api_key,
|
|
28 |
"Authorization": f"Bearer {openai_api_key}"
|
29 |
}
|
30 |
#debug
|
31 |
-
print(f"chat_counter_chatgpt - {chat_counter_chatgpt}")
|
32 |
|
33 |
#Handling the different roles for ChatGPT
|
34 |
if chat_counter_chatgpt != 0 :
|
@@ -59,10 +59,7 @@ def predict_chatgpt(inputs, top_p_chatgpt, temperature_chatgpt, openai_api_key,
|
|
59 |
|
60 |
chat_counter_chatgpt+=1
|
61 |
|
62 |
-
print(f"^^Payload is : {payload}")
|
63 |
history.append(inputs)
|
64 |
-
print(f"^^inputs is : {inputs}")
|
65 |
-
print(f"^^history is : {history}")
|
66 |
|
67 |
# make a POST request to the API endpoint using the requests.post method, passing in stream=True
|
68 |
response = requests.post(API_URL, headers=headers, json=payload, stream=True)
|
@@ -78,13 +75,8 @@ def predict_chatgpt(inputs, top_p_chatgpt, temperature_chatgpt, openai_api_key,
|
|
78 |
# check whether each line is non-empty
|
79 |
if chunk.decode() :
|
80 |
chunk = chunk.decode()
|
81 |
-
print("*************************************")
|
82 |
-
print(chunk)
|
83 |
-
print("*************************************")
|
84 |
# decode each line as response data is in bytes
|
85 |
if len(chunk) > 13 and "content" in json.loads(chunk[6:])['choices'][0]["delta"]:
|
86 |
-
print(json.loads(chunk[6:]))
|
87 |
-
print("*************************************")
|
88 |
partial_words = partial_words + json.loads(chunk[6:])['choices'][0]["delta"]["content"]
|
89 |
if token_counter == 0:
|
90 |
history.append(" " + partial_words)
|
@@ -107,7 +99,7 @@ def predict_together(model: str,
|
|
107 |
|
108 |
client = Client(os.getenv("API_URL_TGTHR")) #get_client(model)
|
109 |
# debug
|
110 |
-
print(f"^^client is - {client}")
|
111 |
user_name, assistant_name = "<human>:", "<bot>:" #get_usernames(model)
|
112 |
|
113 |
history.append(inputs)
|
@@ -167,8 +159,8 @@ def reset_textbox():
|
|
167 |
|
168 |
def reset_chat(chatbot, state):
|
169 |
# debug
|
170 |
-
print(f"^^chatbot value is - {chatbot}")
|
171 |
-
print(f"^^state value is - {state}")
|
172 |
return None, []
|
173 |
|
174 |
|
@@ -198,8 +190,8 @@ with gr.Blocks(css="""#col_container {width: 1000px; margin-left: auto; margin-r
|
|
198 |
openai_api_key = gr.Textbox(type='password', label="Enter your OpenAI API key here for ChatGPT")
|
199 |
inputs = gr.Textbox(placeholder="Hi there!", label="Type an input and press Enter ⤵️ " )
|
200 |
with gr.Column(scale=1):
|
201 |
-
b1 = gr.Button(elem_id = '🏃Run')
|
202 |
-
b2 = gr.Button('🔄Clear up Chatbots!', elem_id = 'clear')
|
203 |
state_chatgpt = gr.State([])
|
204 |
state_together = gr.State([])
|
205 |
|
|
|
28 |
"Authorization": f"Bearer {openai_api_key}"
|
29 |
}
|
30 |
#debug
|
31 |
+
#print(f"chat_counter_chatgpt - {chat_counter_chatgpt}")
|
32 |
|
33 |
#Handling the different roles for ChatGPT
|
34 |
if chat_counter_chatgpt != 0 :
|
|
|
59 |
|
60 |
chat_counter_chatgpt+=1
|
61 |
|
|
|
62 |
history.append(inputs)
|
|
|
|
|
63 |
|
64 |
# make a POST request to the API endpoint using the requests.post method, passing in stream=True
|
65 |
response = requests.post(API_URL, headers=headers, json=payload, stream=True)
|
|
|
75 |
# check whether each line is non-empty
|
76 |
if chunk.decode() :
|
77 |
chunk = chunk.decode()
|
|
|
|
|
|
|
78 |
# decode each line as response data is in bytes
|
79 |
if len(chunk) > 13 and "content" in json.loads(chunk[6:])['choices'][0]["delta"]:
|
|
|
|
|
80 |
partial_words = partial_words + json.loads(chunk[6:])['choices'][0]["delta"]["content"]
|
81 |
if token_counter == 0:
|
82 |
history.append(" " + partial_words)
|
|
|
99 |
|
100 |
client = Client(os.getenv("API_URL_TGTHR")) #get_client(model)
|
101 |
# debug
|
102 |
+
#print(f"^^client is - {client}")
|
103 |
user_name, assistant_name = "<human>:", "<bot>:" #get_usernames(model)
|
104 |
|
105 |
history.append(inputs)
|
|
|
159 |
|
160 |
def reset_chat(chatbot, state):
|
161 |
# debug
|
162 |
+
#print(f"^^chatbot value is - {chatbot}")
|
163 |
+
#print(f"^^state value is - {state}")
|
164 |
return None, []
|
165 |
|
166 |
|
|
|
190 |
openai_api_key = gr.Textbox(type='password', label="Enter your OpenAI API key here for ChatGPT")
|
191 |
inputs = gr.Textbox(placeholder="Hi there!", label="Type an input and press Enter ⤵️ " )
|
192 |
with gr.Column(scale=1):
|
193 |
+
b1 = gr.Button(elem_id = '🏃 Run', elem_id = 'run').style(full_width=True))
|
194 |
+
b2 = gr.Button('🔄Clear up Chatbots!', elem_id = 'clear').style(full_width=True)
|
195 |
state_chatgpt = gr.State([])
|
196 |
state_together = gr.State([])
|
197 |
|