| | import streamlit as st |
| | from ctransformers import AutoModelForCausalLM |
| |
|
| | |
| | llm = AutoModelForCausalLM.from_pretrained( |
| | model_path_or_repo_id="my-model/mistral-7b-instruct-v0.2.Q2_K.gguf", |
| | model_type="mistral", |
| | ) |
| |
|
| | st.title("Conversational Chat with Mistral 🦙🗨️") |
| |
|
| |
|
| | |
| | def generate_response(user_query): |
| | prompt = f"""The user query is '{user_query}'""" |
| | args = { |
| | "prompt": prompt, |
| | "stream": True, |
| | "max_new_tokens": 2048, |
| | "temperature": 0, |
| | } |
| |
|
| | response_placeholder = st.empty() |
| |
|
| | response_so_far = "" |
| |
|
| | for chunk in llm(**args): |
| | response_so_far += chunk |
| | response_placeholder.write(response_so_far) |
| |
|
| | return |
| |
|
| |
|
| | |
| | user_query = st.text_input("Enter your query:", "") |
| |
|
| | if user_query: |
| | |
| | generate_response(user_query) |