Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import random | |
| from huggingface_hub import InferenceClient | |
| client = InferenceClient("deepseek-ai/DeepSeek-R1-Distill-Qwen-32B") | |
| # To change the LLM ^ | |
| def respond(message, history): | |
| messages = [{"role": "system", "content": "You are a friendly chatbot."} # <to change the personality | |
| ] | |
| if history: | |
| messages.extend(history) | |
| messages.append({"role": "user", "content" : message}) | |
| response = client.chat_completion(messages, max_tokens = 100 | |
| # to change the length | |
| ) | |
| print(response ["choices"][0]["message"]["content"].strip()) | |
| return response ['choices'][0]['message']['content'].strip() | |
| def echo(message, history): | |
| choices = ["yes", "ummmmm no no no", "sure", ".....I think you need to rethink your choices", "you deserve a sweet treat", "I don't think so"] | |
| #use random to select one of these choices | |
| random_message = random.choice(choices) | |
| return random_message | |
| chatbot = gr.ChatInterface(respond, type = "messages", theme = "shivi/calm_seafoam") | |
| chatbot.launch(debug=True) |