Git Product home page Git Product logo

Comments (10)

pchalasani avatar pchalasani commented on June 12, 2024

This looks like langroid is not being recognized at all in your environment.

Please following the exact install instructions in the README of the langroid-examples repo: https://github.com/langroid/langroid-examples

If it still doesn't work, let me know the exact steps you took to install langroid.

from langroid.

SaumyaDabhi avatar SaumyaDabhi commented on June 12, 2024

I followed the instructions and the script in the examples folder runs fine, but when I make another file let's say "lagroid.py" and copy the content of script "doc-chat-2.py" into that and run it then am getting the modulenotfound error. why is that?

from langroid.

pchalasani avatar pchalasani commented on June 12, 2024

In that case there may have been an issue with how the contents were copied. For example if you simply rename the script to new.py and run new.py it should of course work.

from langroid.

SaumyaDabhi avatar SaumyaDabhi commented on June 12, 2024

Thank you for your help. Apparently, now I am facing a connection error to OpenAI. I am running the following script:

(1) Get the lease document

import requests
file_url = "https://raw.githubusercontent.com/langroid/langroid-examples/main/examples/docqa/lease.txt"
response = requests.get(file_url)
with open('lease.txt', 'wb') as file:
file.write(response.content)

verify

#with open('lease.txt', 'r') as file:

print(file.read())

from langroid.agent.special import DocChatAgent, DocChatAgentConfig
from langroid.vector_store.lancedb import LanceDBConfig
from langroid.embedding_models.models import OpenAIEmbeddingsConfig
from langroid.embedding_models.models import SentenceTransformerEmbeddingsConfig
from langroid.parsing.parser import ParsingConfig

oai_embed_config = OpenAIEmbeddingsConfig(
model_type="openai",
model_name="text-embedding-ada-002",
dims=1536,
)

(2) Configure DocChatAgent

cfg = DocChatAgentConfig(
name="RAG",
parsing=ParsingConfig(
chunk_size=100,
overlap=20,
n_similar_docs=4,
),
show_stats=False,
cross_encoder_reranking_model="",
llm=llm_cfg,
vecdb=LanceDBConfig(
embedding=oai_embed_config,
collection_name="lease",
replace_collection=True,
),
doc_paths=["lease.txt"]
)

(3) Create DocChatAgent, interact with it

rag_agent = DocChatAgent(cfg)
response = rag_agent.llm_response("What is the start date of the lease?")
assert "2013" in response.content

And the error I got is this and keeps going on:

WARNING:langroid.language_models.utils:OpenAI API request failed with errorConnection error..
Retrying in 111.01054350577557 seconds...
2024-02-21 16:32:21 - WARNING - OpenAI API request failed with errorConnection error..
Retrying in 111.01054350577557 seconds...
WARNING:langroid.language_models.utils:OpenAI API request failed with errorConnection error..
Retrying in 266.38226142682373 seconds...
2024-02-21 16:34:15 - WARNING - OpenAI API request failed with errorConnection error..
Retrying in 266.38226142682373 seconds...
WARNING:langroid.language_models.utils:OpenAI API request failed with errorConnection error..
Retrying in 561.3158388183265 seconds...
2024-02-21 16:38:45 - WARNING - OpenAI API request failed with errorConnection error..
Retrying in 561.3158388183265 seconds...

I have enough balance in my openai account and generated new keys but it does not seem to work and stuck at making connection.

from langroid.

pchalasani avatar pchalasani commented on June 12, 2024

Before trying this example, can you run this and see if it works:

import langroid as lr
import langroid.language_models as lm

llm_config = lm.OpenAIGPTConfig()
agent_config = lr.ChatAgentConfig(
    llm=llm_config,
    system_message="You are a helpful assistant, help me with some questions"
)

agent = lr.ChatAgent(agent_config)
task = lr.Task(agent, interactive=True)

task.run()

from langroid.

SaumyaDabhi avatar SaumyaDabhi commented on June 12, 2024

This works!

from langroid.

pchalasani avatar pchalasani commented on June 12, 2024

This means your OpenAI API Key setup is all good.

Next try this simple doc-chat script :

python3 examples/docqa/rag-local-simple.py

Also see inside the script for other instructions.

I'm suggesting the above scripts since these are the simpler ones to try before the more complex doc-chat-2.py

from langroid.

SaumyaDabhi avatar SaumyaDabhi commented on June 12, 2024

Tried it, and the connection error persists.

from langroid.

SaumyaDabhi avatar SaumyaDabhi commented on June 12, 2024

Hello,
With the recent March 2024 updates, The code I have been running is throwing me this error:

TypeError Traceback (most recent call last)
in <cell line: 1>()
----> 1 from langroid.language_models.openai_gpt import (
2 OpenAIChatModel, OpenAIGPT, OpenAIGPTConfig
3 )

7 frames
/usr/lib/python3.10/typing.py in _type_check(arg, msg, is_argument, module, allow_special_forms)
174 return arg
175 if not callable(arg):
--> 176 raise TypeError(f"{msg} Got {arg!r:.100}.")
177 return arg
178

TypeError: Tuple[t0, t1, ...]: each t must be a type. Got <module 'PIL.Image' from '/usr/local/lib/python3.10/dist-packages/PIL/Image.py'>.

The following is the code I am using:

from langroid.language_models.openai_gpt import (
OpenAIChatModel, OpenAIGPT, OpenAIGPTConfig
)

It was working fine before, but after the recent updates, it is not.

from langroid.

pchalasani avatar pchalasani commented on June 12, 2024

Your error trace shows python3.10. Langroid requires 3.11 as it says in the README.

from langroid.

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.