Update app.py
Browse files
app.py
CHANGED
@@ -60,6 +60,56 @@
|
|
60 |
# )
|
61 |
|
62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
# if __name__ == "__main__":
|
64 |
# demo.launch()
|
65 |
|
@@ -73,10 +123,11 @@ client = InferenceClient("Qwen/Qwen2.5-Coder-32B-Instruct")
|
|
73 |
|
74 |
def respond(message, history: list[tuple[str, str]]):
|
75 |
system_message = (
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
|
|
80 |
max_tokens = 2048
|
81 |
temperature = 0.7
|
82 |
top_p = 0.95
|
@@ -112,3 +163,4 @@ demo = gr.ChatInterface(respond)
|
|
112 |
|
113 |
if __name__ == "__main__":
|
114 |
demo.launch()
|
|
|
|
60 |
# )
|
61 |
|
62 |
|
63 |
+
# if __name__ == "__main__":
|
64 |
+
# demo.launch()
|
65 |
+
|
66 |
+
import gradio as gr
|
67 |
+
from huggingface_hub import InferenceClient
|
68 |
+
|
69 |
+
"""
|
70 |
+
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
71 |
+
"""
|
72 |
+
# client = InferenceClient("Qwen/Qwen2.5-Coder-32B-Instruct")
|
73 |
+
|
74 |
+
# def respond(message, history: list[tuple[str, str]]):
|
75 |
+
# system_message = (
|
76 |
+
# "You are a helpful and experienced coding assistant specialized in web development. "
|
77 |
+
# "Help the user by generating complete and functional code for building websites. "
|
78 |
+
# "You can provide HTML, CSS, JavaScript, and backend code (like Flask, Node.js, etc.) based on their requirements. "
|
79 |
+
# "Break down the tasks clearly if needed, and be friendly and supportive in your responses.")
|
80 |
+
# max_tokens = 2048
|
81 |
+
# temperature = 0.7
|
82 |
+
# top_p = 0.95
|
83 |
+
|
84 |
+
# messages = [{"role": "system", "content": system_message}]
|
85 |
+
|
86 |
+
# for val in history:
|
87 |
+
# if val[0]:
|
88 |
+
# messages.append({"role": "user", "content": val[0]})
|
89 |
+
# if val[1]:
|
90 |
+
# messages.append({"role": "assistant", "content": val[1]})
|
91 |
+
|
92 |
+
# messages.append({"role": "user", "content": message})
|
93 |
+
|
94 |
+
# response = ""
|
95 |
+
|
96 |
+
# for message in client.chat_completion(
|
97 |
+
# messages,
|
98 |
+
# max_tokens=max_tokens,
|
99 |
+
# stream=True,
|
100 |
+
# temperature=temperature,
|
101 |
+
# top_p=top_p,
|
102 |
+
# ):
|
103 |
+
# token = message.choices[0].delta.content
|
104 |
+
|
105 |
+
# response += token
|
106 |
+
# yield response
|
107 |
+
|
108 |
+
# """
|
109 |
+
# For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
110 |
+
# """
|
111 |
+
# demo = gr.ChatInterface(respond)
|
112 |
+
|
113 |
# if __name__ == "__main__":
|
114 |
# demo.launch()
|
115 |
|
|
|
123 |
|
124 |
def respond(message, history: list[tuple[str, str]]):
|
125 |
system_message = (
|
126 |
+
"You are a helpful and experienced coding assistant specialized in web development. "
|
127 |
+
"Help the user by generating complete and functional code for building websites. "
|
128 |
+
"You can provide HTML, CSS, JavaScript, and backend code (like Flask, Node.js, etc.) based on their requirements. "
|
129 |
+
"Break down the tasks clearly if needed, and be friendly and supportive in your responses."
|
130 |
+
)
|
131 |
max_tokens = 2048
|
132 |
temperature = 0.7
|
133 |
top_p = 0.95
|
|
|
163 |
|
164 |
if __name__ == "__main__":
|
165 |
demo.launch()
|
166 |
+
|