Coder Social home page Coder Social logo

Issue on docs about docs HOT 10 CLOSED

xg35 avatar xg35 commented on July 17, 2024
Issue on docs

from docs.

Comments (10)

xg35 avatar xg35 commented on July 17, 2024 1
image

that indeed did the job. now looks like this

from docs.

willydouhard avatar willydouhard commented on July 17, 2024

Nice catch, what version of langflow are you using? Can you try upgrading it? Or maybe they released a breaking change.

from docs.

xg35 avatar xg35 commented on July 17, 2024

Langflow v0.2.7

from docs.

willydouhard avatar willydouhard commented on July 17, 2024

This seems pretty outdated, can you run pip -U langflow and try again?

from docs.

xg35 avatar xg35 commented on July 17, 2024

yeah updated it to 0.4.16 and similar error:

TypeError: load_flow_from_json() got an unexpected keyword argument 'flow'
2023-09-13 16:32:38 - 'NoneType' object has no attribute 'agent'
Traceback (most recent call last):
File "/Users/simonau/Documents/Lending/env/lib/python3.11/site-packages/chainlit/utils.py", line 40, in wrapper
return await user_function(**params_values)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/simonau/Documents/Lending/main_tool_langflow.py", line 29, in main
flow.agent.llm_chain.llm.streaming = True
^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'agent'

from docs.

willydouhard avatar willydouhard commented on July 17, 2024

So this error is a bit different, the flow was successfully loaded but it no longer have an agent attribute. But at least this is reaching the code of your app file.

from docs.

xg35 avatar xg35 commented on July 17, 2024

import json

from langchain.agents import AgentExecutor
from langflow import load_flow_from_json
from chainlit.langflow import load_flow
import chainlit as cl

#import os

#os.environ["OPENAI_API_KEY"] = os.getenv("OPENAI_API_KEY")
#os.environ["SERPAPI_API_KEY"] = os.getenv("SERPAPI_API_KEY")

with open("./schema.json", "r") as f:
schema = json.load(f)

@cl.on_chat_start
async def start():
flow = await load_flow(schema=schema)
cl.user_session.set("flow", flow)

@cl.on_message
async def main(message):
# Load the flow from the user session
flow = cl.user_session.get("flow") # type: AgentExecutor

# Enable streaming
flow.agent.llm_chain.llm.streaming = True

# Run the flow
res = await cl.make_async(flow.run)(
    message, callbacks=[cl.LangchainCallbackHandler()]
)

# Send the response
await cl.Message(content=res).send()

This is the exact code.

from docs.

willydouhard avatar willydouhard commented on July 17, 2024

maybe update the main function like so:

@cl.on_message
async def main(message):
# Load the flow from the user session
flow = cl.user_session.get("flow") # type: AgentExecutor

# Run the flow
res = await cl.make_async(flow)(
    message, callbacks=[cl.LangchainCallbackHandler()]
)

# Send the response
await cl.Message(content=res).send()

from docs.

xg35 avatar xg35 commented on July 17, 2024

Any idea how i can get it parse it correctly?

from docs.

willydouhard avatar willydouhard commented on July 17, 2024

What do you mean by "parsing"?

from docs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.