Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: unsupported operand type(s) for |: '_GenericAlias' and 'type' #87

Closed
IntelligenzaArtificiale opened this issue Sep 26, 2023 · 8 comments · Fixed by #88
Closed
Assignees
Labels
bug bug!

Comments

@IntelligenzaArtificiale

Hi guys,

i have this error with new version

class ChatBot:

  File "/home/adminuser/venv/lib/python3.9/site-packages/hugchat/hugchat.py", line 494, in ChatBot

    ) -> typing.Generator[dict, None, None] | dict:

TypeError: unsupported operand type(s) for |: '_GenericAlias' and 'type'
@Soulter
Copy link
Owner

Soulter commented Sep 26, 2023

"|" is not available on python3.9. We'll fix it soon to adapt lower python interpreters, you can degrade to v0.2.7 when we are fixing the problem.

@Soulter Soulter added the bug bug! label Sep 26, 2023
@IntelligenzaArtificiale
Copy link
Author

thank you, you are the best 🤗

@RockChinQ RockChinQ linked a pull request Sep 26, 2023 that will close this issue
@IntelligenzaArtificiale
Copy link
Author

I Love u guys 🚀

I have some app based on our api 😅

Could it help you if I develop a custom LLM connector for your API's langchain?

Some time ago with your bee I managed to run AUTOGPT without paying the API.

With this custom langchain LLM wrapper anyone can develop for free app like talk with pdf, python interpreter, etc...

Let me know if you're interested :)

@IntelligenzaArtificiale
Copy link
Author

Of course I would develop it for free for you, I respect you very much.

If you want, I am also willing to send you the code without taking credit

@Soulter
Copy link
Owner

Soulter commented Sep 27, 2023

I Love u guys 🚀

I have some app based on our api 😅

Could it help you if I develop a custom LLM connector for your API's langchain?

Some time ago with your bee I managed to run AUTOGPT without paying the API.

With this custom langchain LLM wrapper anyone can develop for free app like talk with pdf, python interpreter, etc...

Let me know if you're interested :)

wow that's cool, feel free to develop it!

@IntelligenzaArtificiale
Copy link
Author

IntelligenzaArtificiale commented Sep 27, 2023

Hy guys 🚀,
I hope I don't disturb you.

I developed LLM langchain custom wrapper. Now you can use this api with langchain in a similar way to how OpenAI models are used.

Try this example:
This example demonstrates how to use HCA to interact with a language model to answer a question based on a context template. Users can modify the query in the prompt_template.format() call to ask different questions and get responses from the language model. This showcases the flexibility of HCA in handling various NLP tasks.

from HCA import HCA
from langchain import PromptTemplate

# Initialize the HCA instance with your HuggingFace credentials
llm = HCA(email="YOUR_EMAIL", password="YOUR_PASSWORD", log=True, model=1)

# Define a template for your prompt
template = """Answer the question based on the context below. If the
question cannot be answered using the information provided, answer
with "I don't know".

Context: Large Language Models (LLMs) are the latest models used in NLP.
Their superior performance over smaller models has made them incredibly
useful for developers building NLP-enabled applications. These models
can be accessed via Hugging Face's `transformers` library, via OpenAI
using the `openai` library, and via Cohere using the `cohere` library.

Question: {query}

Answer: """

# Create a PromptTemplate for generating prompts
prompt_template = PromptTemplate(
    input_variables=["query"],
    template=template
)

# Generate a response to a specific question
response = llm(
    prompt_template.format(
        query="Which libraries and model providers offer LLMs?"
    )
)

print(response)

LINK FOR CUSTOM LLM WRAPPER🤗

@IntelligenzaArtificiale
Copy link
Author

IntelligenzaArtificiale commented Sep 27, 2023

Now evryone can create and develop custom langchain agent based on HuggingChat model :)

@Soulter thanks for this opportunity

@IntelligenzaArtificiale
Copy link
Author

This is another simple example that shows the potential of the custom langchain connector.

from HCA import HCA

from langchain.agents import initialize_agent, AgentType
from langchain.tools.yahoo_finance_news import YahooFinanceNewsTool


llm = HCA(email="yourEmail", password="YourPSW" , model=0, temperature=0.1)

tools = [YahooFinanceNewsTool()]
agent_chain = initialize_agent(
    tools,
    llm,
    agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
    verbose=True,
)

agent_chain.run(
    "What happens today with Microsoft stocks?",
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug bug!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants