File size: 1,274 Bytes
d660b02
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from llm_engineering.infrastructure.inference_pipeline_api import rag
import gradio as gr
from langchain.schema import AIMessage, HumanMessage, SystemMessage


def predict(message, history):
    history_langchain_format = []
    for msg in history:
        if msg['role'] == "user":
            history_langchain_format.append(HumanMessage(content=msg['content']))
        elif msg['role'] == "assistant":
            history_langchain_format.append(AIMessage(content=msg['content']))
    query = HumanMessage(content=message)
    gpt_response = rag(query, history_langchain_format)
    history_langchain_format.append(query)

    return gpt_response.content

predefined_questions = [
    "Tell me how can I navigate to a specific pose - include replanning aspects in your answer.",
    "Can you provide me with code for this task?",
]

demo = gr.ChatInterface(
    predict,
    type="messages",
    examples=[ "Tell me how can I navigate to a specific pose - include replanning aspects in your answer.",
    "Can you provide me with code for this task?"],
    description="Ask specific questions related to ROS2 navigation, motion planning, and simulation",
    stop_btn=True,
    head="RAG System for ROS2 Robotics",
)

demo.launch(server_name="0.0.0.0", server_port=7860)