Giter Club home page Giter Club logo

Comments (4)

niknak6 avatar niknak6 commented on August 22, 2024 1

Thanks for trying to help, I figured it was just a novice mistake somewhere along the way. Error:

File "{HOME}/redenv/lib/python3.11/site-packages/requests/models.py", line 975, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

from meta-ai-api.

Strvm avatar Strvm commented on August 22, 2024

Hi, the python method will return a python dictionary (which could be converted into JSON). Could I see the code you are using?

Thanks!

from meta-ai-api.

niknak6 avatar niknak6 commented on August 22, 2024

I'm likely not handling the response correctly.

I attempted to just make a super simple Redbot based Discord bot as a proof of concept, using the command !meta [query]:

from redbot.core import commands
from meta_ai_api import MetaAI

class MetaBot(commands.Cog):

    def __init__(self, bot):
        self.bot = bot
        self.ai = MetaAI()

    @commands.command()
    async def meta(self, ctx, *, query: str):
        """Send a query to Meta AI and get a response."""
        try:
            response = self.ai.prompt(message=query)
            if response:
                await ctx.send(response['message'])
                if 'sources' in response:
                    sources = '\n'.join([f"[{src['title']}]({src['link']})" for src in response['sources']])
                    await ctx.send(f"**Sources:**\n{sources}")
            else:
                await ctx.send("No response received from Meta AI.")
        except Exception as e:
            await ctx.send(f"Error occurred: {str(e)}")

from meta-ai-api.

Strvm avatar Strvm commented on August 22, 2024

I was able to get sources using similar code to yours:

response = ai.prompt(message="Whats the weather in San Francisco today? And what is the date?", stream=False)
sources = '\n'.join([f"[{src['title']}]({src['link']})" for src in response['sources']])
print(sources)
[WolframAlpha](https://www.wolframalpha.com/input?i=San+Francisco+weather+today+and+date)
[San Francisco 14 Day Extended Forecast - Weather - Time and Date](https://www.timeanddate.com/weather/usa/san-francisco/ext)
[Hourly forecast for San Francisco, California, USA - Time and Date](https://www.timeanddate.com/weather/usa/san-francisco/hourly)
[Past Weather in San Francisco, California, USA - Time and Date](https://www.timeanddate.com/weather/usa/san-francisco/historic)
[Weather for San Francisco, California, USA - Time and Date](https://www.timeanddate.com/weather/usa/san-francisco)

Not sure what seems to be the issue on your side, do you get an error?

from meta-ai-api.

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.