File size: 890 Bytes
29d0869 1315368 91328fb 74fa020 b77a8b6 1315368 d775587 1315368 d775587 1315368 91328fb d775587 91328fb d775587 91328fb b77a8b6 91328fb b77a8b6 91328fb d775587 b77a8b6 9346553 91328fb b77a8b6 d775587 91328fb d775587 |
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# Import required libraries
import gradio as gr
from huggingface_hub import InferenceClient
from transformers import pipeline
import torch
import huggingfacehub as infer
import threading
import time
import tensorflow as tf
from transformers import pipeline
# Initialize the text generation pipeline with the specified model
pipe = pipeline("text-generation", model="chargoddard/Yi-34B-Llama", device=0)
def respond(
message,
response = ""
# Generate the response using the pipeline
result = pipe(
messages[-1]["content"],
max_length=max_tokens,
num_return_sequences=1,
temperature=temperature,
top_p=top_p,
)
response = result[0]['generated_text']
yield response)
# Gradio interface setup
demo = gr.ChatInterface(
respond,
additional_inputs=[
],
)
if __name__ == "__main__":
demo.launch() |