Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,23 +1,22 @@
|
|
| 1 |
-
import subprocess
|
| 2 |
import os
|
| 3 |
import gradio as gr
|
| 4 |
from groq import Groq
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
api_key=os.environ.get("Groq_Api_Key"),
|
| 9 |
-
)
|
| 10 |
|
|
|
|
|
|
|
| 11 |
|
| 12 |
stream = client.chat.completions.create(
|
| 13 |
messages=[
|
| 14 |
{"role": "system", "content": "you are a helpful assistant."},
|
| 15 |
{"role": "user", "content": input_text}
|
| 16 |
],
|
| 17 |
-
model=
|
| 18 |
-
temperature=
|
| 19 |
-
max_tokens=
|
| 20 |
-
top_p=
|
| 21 |
stop=None,
|
| 22 |
stream=True,
|
| 23 |
)
|
|
@@ -30,14 +29,18 @@ def generate_response(input_text):
|
|
| 30 |
|
| 31 |
return response
|
| 32 |
|
| 33 |
-
# Define the Gradio
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
-
gr.
|
| 38 |
fn=generate_response,
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
title="
|
| 42 |
-
description="
|
| 43 |
-
).launch(
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
import gradio as gr
|
| 3 |
from groq import Groq
|
| 4 |
|
| 5 |
+
import gradio as gr
|
| 6 |
+
from groq import Groq
|
|
|
|
|
|
|
| 7 |
|
| 8 |
+
def generate_response(input_text, model, temperature, max_tokens, top_p):
|
| 9 |
+
client = Groq()
|
| 10 |
|
| 11 |
stream = client.chat.completions.create(
|
| 12 |
messages=[
|
| 13 |
{"role": "system", "content": "you are a helpful assistant."},
|
| 14 |
{"role": "user", "content": input_text}
|
| 15 |
],
|
| 16 |
+
model=model,
|
| 17 |
+
temperature=temperature,
|
| 18 |
+
max_tokens=max_tokens,
|
| 19 |
+
top_p=top_p,
|
| 20 |
stop=None,
|
| 21 |
stream=True,
|
| 22 |
)
|
|
|
|
| 29 |
|
| 30 |
return response
|
| 31 |
|
| 32 |
+
# Define the Gradio chat interface
|
| 33 |
+
additional_inputs = [
|
| 34 |
+
gr.Dropdown(choices=["mixtral-8x7b-32768", "mixtral-12x7b-32768"], label="Model"),
|
| 35 |
+
gr.Slider(minimum=0.0, maximum=1.0, step=0.01, label="Temperature"),
|
| 36 |
+
gr.Slider(minimum=1, maximum=4096, step=1, label="Max Tokens"),
|
| 37 |
+
gr.Slider(minimum=0.0, maximum=1.0, step=0.01, label="Top P"),
|
| 38 |
+
]
|
| 39 |
|
| 40 |
+
gr.ChatInterface(
|
| 41 |
fn=generate_response,
|
| 42 |
+
chatbot=gr.Chatbot(show_label=False, show_share_button=False, show_copy_button=True, likeable=True, layout="panel"),
|
| 43 |
+
additional_inputs=additional_inputs,
|
| 44 |
+
title="Groq API LLMs AI Models",
|
| 45 |
+
description="Using https://groq.com/ api, ofc as its free it will have some limitations so its better if you duplicate this space with your own api key<br>Hugging Face Space by [Nick088](https://linktr.ee/Nick088",
|
| 46 |
+
).launch()
|