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

POC: AI #65

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

POC: AI #65

wants to merge 5 commits into from

Conversation

howardt12345
Copy link
Member

Proof of concept of LLM implementation

Requires the following environment variables in .env:

OPENAI_BASE_URL=[API URL]
OPENAI_API_KEY=[OpenAI API key]
LLM_MODEL=[model]

You could use an OpenAI API key to test it

For use with Ollama models, refer to this. The bot deployment will be using a model deployed on my server

@howardt12345 howardt12345 changed the title POC: LLM POC: AI Jul 5, 2024
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try this one-liner

Or you could use numpy.array_split for this, though I guess it's a little overkill and you need to convert them all back into strings later

],
stream=False
)
return completion.choices[0].message.content
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs error handling pain (a try catch maybe)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will need to fix integration tests for this lol (monkeypatch away OpenAI)

models = list_models()
await interaction.followup.send("\n".join(models))
except Exception as e:
await interaction.followup.send(f"An error occurred: {e}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ephemeral=True on error maybe

guilds=guilds,
)
@app_commands.describe(question="The question you want to ask the AI")
async def llm(interaction: discord.Interaction, question: str, model: str = ""):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I think the list of models already be specified as discord Choices
  2. Provide a default one since users probably don't care/know the differences between each model

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

Successfully merging this pull request may close these issues.

2 participants