Spaces:
Sleeping
Sleeping
File size: 883 Bytes
1ad978f d69e156 71c54ff 846cd15 1ad978f 846cd15 d69e156 846cd15 1ad978f d69e156 71c54ff 0285186 71c54ff 1ad978f d69e156 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | import streamlit as st
from huggingface_hub import InferenceClient
from modules.inference.instruct import infer, load_model
import os
token = os.environ["HF_TOKEN"]
client = InferenceClient(model="meta-llama/Llama-3.2-1B-Instruct", token=token)
st.write("## Ask your Local LLM")
text_input = st.text_input("Query", value="Why is the sky Blue")
submit = st.button("Submit")
# @st.cache_resource
# def load_model_cached():
# return load_model()
# model = load_model_cached()
if submit:
# response = infer(model, text_input)
# response
output = client.chat.completions.create(
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": text_input},
],
stream=True,
max_tokens=1024,
)
for chunk in output:
st.write(chunk.choices[0].delta.content) |