below code is not able to show grpahs at frontend , rather it returns code , #10835
Replies: 1 comment
-
🤖 Hello, From the code you've shared, it seems like you're trying to display a graph on the frontend, but the code is not designed to do that. The LangChain framework, as far as I can see from the repository, does not provide built-in methods for displaying graphs in a frontend application. The def draw_graphviz(self, **kwargs: Any) -> None:
from networkx.drawing.nx_agraph import to_agraph
try:
import pygraphviz # noqa: F401
except ImportError as e:
# error handling code omitted for brevity
graph = to_agraph(self._graph) # --> pygraphviz.agraph.AGraph
graph.layout(prog=kwargs.get("prog", "dot"))
graph.draw(kwargs.get("path", "graph.svg")) To display the graph on the frontend, you would need to modify this function to return a reference to the file, or to return the graph data in a format that can be used by a frontend application. Also, I noticed you've included an image in your message. Unfortunately, I'm unable to view images. If the image contains relevant information or code, could you please provide that information in text format? Let me know if you need further assistance. SourcesThis response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
Beta Was this translation helpful? Give feedback.
-
import pandas as pd
import streamlit as st
from langchain.chat_models import ChatOpenAI
from langchain.agents.agent_toolkits import create_pandas_dataframe_agent
from langchain.agents.agent_types import AgentType
df = pd.read_csv('/Users/siddheshphapale/Desktop/project/sqlcsv.csv')
llm = ChatOpenAI(openai_api_key= "my key" , temperature=0 ,max_tokens= 500 , verbose= False)
agent = create_pandas_dataframe_agent(llm, df, agent_type=AgentType.OPENAI_FUNCTIONS)
from langsmith import Client
client = Client()
def send_feedback(run_id, score):
client.create_feedback(run_id, "user_score", score=score)
st.set_page_config(page_title='🦜🔗 Ask the CSV App')
st.title('🦜🔗 Ask the CSV App')
query_text = st.text_input('Enter your question:', placeholder = 'Who was in cabin C128?')
Form input and query
result = None
with st.form('myform', clear_on_submit=True):
submitted = st.form_submit_button('Submit')
if submitted:
with st.spinner('Calculating...'):
response = agent({"input": query_text}, include_run_info=True)
result = response["output"]
run_id = response["__run"].run_id
if result is not None:
st.info(result)
col_blank, col_text, col1, col2 = st.columns([10, 2,1,1])
with col_text:
st.text("Feedback:")
with col1:
st.button("👍", on_click=send_feedback, args=(run_id, 1))
with col2:
st.button("👎", on_click=send_feedback, args=(run_id, 0))
Beta Was this translation helpful? Give feedback.
All reactions