Spaces:
Build error
Build error
Update app.py
Browse files16 unmodified lines171819202122232439 unmodified lines6465666768697071727374757610 unmodified lines8788899091929394959697989916 unmodified linesHF_TOKEN = os.environ.get("HF_TOKEN", None)TITLE = "<h1><center>Mistral-lab</center></h1>"PLACEHOLDER = """<center><p>Chat with Mistral AI LLM.</p>39 unmodified linesprint(f'history: {history}')conversation = []# for prompt, answer in history:# conversation.append(UserMessage(content=prompt))# conversation.append(AssistantMessage(content=answer))if history:conversation.extend(history)conversation.append(UserMessage(content=message))completion_request = ChatCompletionRequest(messages=conversation)tokens = tokenizer.encode_chat_completion(completion_request).tokens10 unmodified linesfor i in range(len(result)):time.sleep(0.05)yield result[: i + 1]with gr.Blocks(theme="ocean", css=CSS) as demo:gr.HTML(TITLE)gr.DuplicateButton(value="Duplicate Space for private use", elem_classes="duplicate-button")gr.ChatInterface(fn=stream_chat,type="messages",fill_height=True,examples=[["Help me study vocabulary: write a sentence for me to fill in the blank, and I'll try to pick the correct option."],16 unmodified lines17181920212239 unmodified lines62636465666768697071727374757610 unmodified lines8788899091929394959697989910010110216 unmodified linesHF_TOKEN = os.environ.get("HF_TOKEN", None)PLACEHOLDER = """<center><p>Chat with Mistral AI LLM.</p>39 unmodified linesprint(f'history: {history}')conversation = []for prompt, answer in history:conversation.append(UserMessage(content=prompt))conversation.append(AssistantMessage(content=answer))# if history:# conversation.extend(history)conversation.append(UserMessage(content=message))print(f'history: {conversation}')completion_request = ChatCompletionRequest(messages=conversation)tokens = tokenizer.encode_chat_completion(completion_request).tokens10 unmodified linesfor i in range(len(result)):time.sleep(0.05)yield result[: i + 1]chatbot = gr.Chatbot(height=600, placeholder=PLACEHOLDER)with gr.Blocks(theme="citrus", css=CSS) as demo:gr.DuplicateButton(value="Duplicate Space for private use", elem_classes="duplicate-button")gr.ChatInterface(fn=stream_chat,title="Mistral-lab",chatbot=chatbot,#type="messages",fill_height=True,examples=[["Help me study vocabulary: write a sentence for me to fill in the blank, and I'll try to pick the correct option."],
app.py+15-12