|
import gradio as gr |
|
from datasets import load_dataset |
|
|
|
|
|
model = gr.load("models/Qwen/Qwen2.5-Coder-32B-Instruct") |
|
|
|
|
|
dataset = load_dataset("Eim/laravel-docs") |
|
|
|
|
|
def chatbot(input_text): |
|
|
|
relevant_docs = [ |
|
doc["content"] for doc in dataset["train"] |
|
if input_text.lower() in doc["content"].lower() |
|
] |
|
|
|
|
|
model_response = model(input_text) |
|
|
|
|
|
if relevant_docs: |
|
additional_info = "\n\n".join(relevant_docs[:3]) |
|
return f"{model_response}\n\nDocumentaci贸n relevante:\n{additional_info}" |
|
else: |
|
return model_response |
|
|
|
|
|
gr.Interface(fn=chatbot, inputs="text", outputs="text").launch() |
|
|