Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
|
6 |
import transformers
|
7 |
import torch
|
@@ -103,52 +103,3 @@ with gr.Blocks() as demo:
|
|
103 |
|
104 |
demo.queue()
|
105 |
demo.launch(debug=True)
|
106 |
-
'''
|
107 |
-
|
108 |
-
import os
|
109 |
-
from groq import Groq
|
110 |
-
import gradio as gr
|
111 |
-
|
112 |
-
client = Groq(api_key = os.environ.get("GROQ_API_KEY"), )
|
113 |
-
|
114 |
-
system_prompt = {
|
115 |
-
"role": "system",
|
116 |
-
"content":
|
117 |
-
"You are a useful assistant. I would appreciate it if you reply with efficient answers. "
|
118 |
-
}
|
119 |
-
|
120 |
-
async def chat_groq(message, history):
|
121 |
-
|
122 |
-
messages = [system_prompt]
|
123 |
-
|
124 |
-
for msg in history:
|
125 |
-
messages.append({"role": "user", "content": str(msg[0])})
|
126 |
-
messages.append({"role": "assistant", "content": str(msg[1])})
|
127 |
-
|
128 |
-
messages.append({"role": "user", "content": str (message)})
|
129 |
-
|
130 |
-
response_content = ''
|
131 |
-
|
132 |
-
stream = client.chat.completions.create(
|
133 |
-
model="llama3-8b-8192",
|
134 |
-
messages=messages,
|
135 |
-
max_tokens=1024,
|
136 |
-
temperature=1.3,
|
137 |
-
stream=True
|
138 |
-
)
|
139 |
-
|
140 |
-
for chunk in stream:
|
141 |
-
content = chunk.choices[0].delta.content
|
142 |
-
if content:
|
143 |
-
response_content += chunk. choices[0].delta.content
|
144 |
-
yield response_content
|
145 |
-
|
146 |
-
with gr. Blocks(theme=gr.themes.Monochrome(), fill_height=True) as demo:
|
147 |
-
gr.ChatInterface(chat_groq,
|
148 |
-
clear_btn=None,
|
149 |
-
undo_btn=None,
|
150 |
-
retry_btn=None,
|
151 |
-
)
|
152 |
-
|
153 |
-
demo.queue()
|
154 |
-
demo.launch()'''
|
|
|
1 |
|
2 |
+
!pip install -U "transformers==4.40.0" --upgrade
|
3 |
+
!pip install -i https://pypi.org/simple/ bitsandbytes
|
4 |
+
!pip install accelerate
|
5 |
|
6 |
import transformers
|
7 |
import torch
|
|
|
103 |
|
104 |
demo.queue()
|
105 |
demo.launch(debug=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|