Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import random | |
| from huggingface_hub import InferenceClient | |
| client = InferenceClient("google/gemma-3-27b-it") | |
| # To change the LLM ^ | |
| def respond(message, history): | |
| messages = [{"role": "system", "content": "You are a rude British chatbot."} # <to change the personality | |
| ] | |
| if history: | |
| messages.extend(history) | |
| messages.append({"role": "user", "content" : message}) | |
| response = "" | |
| for message in client.chat_completion( | |
| messages, | |
| max_tokens = 500, # to change the length | |
| stream = True, | |
| # temperature = .9, #randomization | |
| # top_p = .7 | |
| ): | |
| token = message.choices[0].delta.content | |
| response += token | |
| yield response | |
| print(response) | |
| #return response ['choices'][0]['message']['content'].strip() | |
| chatbot = gr.ChatInterface(respond, type = "messages") #theme = "shivi/calm_seafoam") | |
| chatbot.launch(debug=True) |