Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -218,35 +218,5 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 218 |
example3_button.click(fn=lambda: gr.update(value=example_messages["JEE Main 2025 Probability & Statistics"]), inputs=None, outputs=user_input)
|
| 219 |
example4_button.click(fn=lambda: gr.update(value=example_messages["JEE Main 2025 Laws of Motion"]), inputs=None, outputs=user_input)
|
| 220 |
|
| 221 |
-
demo.launch(
|
| 222 |
-
|
| 223 |
-
Now, i want to host it on an inference endpoint which can be called as follows:
|
| 224 |
-
|
| 225 |
-
from openai import OpenAI
|
| 226 |
-
|
| 227 |
-
client = OpenAI(
|
| 228 |
-
base_url = "https://a7g1ajqixo23revq.us-east-1.aws.endpoints.huggingface.cloud/v1/",
|
| 229 |
-
api_key = "hf_XXXXX"
|
| 230 |
-
)
|
| 231 |
-
|
| 232 |
-
chat_completion = client.chat.completions.create(
|
| 233 |
-
model="tgi",
|
| 234 |
-
messages=[
|
| 235 |
-
{
|
| 236 |
-
"role": "user",
|
| 237 |
-
"content": "What is deep learning?"
|
| 238 |
-
}
|
| 239 |
-
],
|
| 240 |
-
top_p=None,
|
| 241 |
-
temperature=None,
|
| 242 |
-
max_tokens=150,
|
| 243 |
-
stream=True,
|
| 244 |
-
seed=None,
|
| 245 |
-
stop=None,
|
| 246 |
-
frequency_penalty=None,
|
| 247 |
-
presence_penalty=None
|
| 248 |
-
)
|
| 249 |
-
|
| 250 |
-
for message in chat_completion:
|
| 251 |
-
print(message.choices[0].delta.content, end = "")
|
| 252 |
|
|
|
|
| 218 |
example3_button.click(fn=lambda: gr.update(value=example_messages["JEE Main 2025 Probability & Statistics"]), inputs=None, outputs=user_input)
|
| 219 |
example4_button.click(fn=lambda: gr.update(value=example_messages["JEE Main 2025 Laws of Motion"]), inputs=None, outputs=user_input)
|
| 220 |
|
| 221 |
+
demo.launch(ssr_mode=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 222 |
|