Spaces:
Runtime error
Runtime error
File size: 1,174 Bytes
6433e18 96c3959 6433e18 d8e07ba 6433e18 d8e07ba 6433e18 d8e07ba 6433e18 d8e07ba 6433e18 d8e07ba 6433e18 d8e07ba 6433e18 |
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 33 |
# import streamlit as st
# from PIL import Image
# import base64
# import transformers
# model_name = 'Intel/neural-chat-7b-v3-1'
# model = transformers.AutoModelForCausalLM.from_pretrained(model_name)
# tokenizer = transformers.AutoTokenizer.from_pretrained(model_name)
# def generate_response(system_input, user_input):
# # Format the input using the provided template
# prompt = f"### System:\n{system_input}\n### User:\n{user_input}\n### Assistant:\n"
# # Tokenize and encode the prompt
# inputs = tokenizer.encode(prompt, return_tensors="pt", add_special_tokens=False)
# # Generate a response
# outputs = model.generate(inputs, max_length=1000, num_return_sequences=1)
# response = tokenizer.decode(outputs[0], skip_special_tokens=True)
# # Extract only the assistant's response
# return response.split("### Assistant:\n")[-1]
# # Example usage
# system_input = "You are a employee in the customer succes department of a company called Retraced that works in sustainability and traceability"
# prompt = st.text_input(str("Insert here you prompt?"))
# response = generate_response(system_input, prompt)
# st.write(response)
|