move wolfram out of its own file
This commit is contained in:
parent
c44660df0e
commit
a4b13008aa
@ -83,12 +83,15 @@ class ActualUtils(commands.Cog):
|
|||||||
description="The query you want to pass to wolfram alpha",
|
description="The query you want to pass to wolfram alpha",
|
||||||
)
|
)
|
||||||
async def wolfram(self, ctx, query):
|
async def wolfram(self, ctx, query):
|
||||||
import questions
|
import wolframalpha
|
||||||
|
|
||||||
|
client = wolframalpha.Client(os.getenv("wolfram_token"))
|
||||||
await ctx.defer()
|
await ctx.defer()
|
||||||
await ctx.send_followup(
|
try:
|
||||||
questions.answer_question(query),
|
res = client.query(query)
|
||||||
)
|
return await ctx.send_followup(next(res.results).text)
|
||||||
|
except Exception:
|
||||||
|
return await ctx.send_followup("Sorry, I'm unable to answer that")
|
||||||
|
|
||||||
@commands.has_role("Track day gamers")
|
@commands.has_role("Track day gamers")
|
||||||
@commands.slash_command(
|
@commands.slash_command(
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
import os
|
|
||||||
import wolframalpha
|
|
||||||
|
|
||||||
import help_methods
|
|
||||||
|
|
||||||
|
|
||||||
def answer_question(message):
|
|
||||||
"""
|
|
||||||
answer_question(message)
|
|
||||||
|
|
||||||
Submits a request to the wolfram API and returns the response
|
|
||||||
If no answer is found, tries wikipedia. If that fails, apologizes
|
|
||||||
"""
|
|
||||||
|
|
||||||
client = wolframalpha.Client(os.getenv("wolfram_token"))
|
|
||||||
try:
|
|
||||||
res = client.query(message)
|
|
||||||
return next(res.results).text
|
|
||||||
except Exception:
|
|
||||||
return "Sorry, I'm unable to answer that"
|
|
||||||
|
|
||||||
return help_methods.get_help_message("message")
|
|
||||||
|
|
||||||
|
|
||||||
def open_ai(prompt):
|
|
||||||
import os
|
|
||||||
import openai
|
|
||||||
|
|
||||||
openai.api_key = os.getenv("OPENAI_API_KEY")
|
|
||||||
|
|
||||||
response = openai.Completion.create(
|
|
||||||
model="text-ada-001",
|
|
||||||
prompt=prompt,
|
|
||||||
temperature=0.7,
|
|
||||||
max_tokens=256,
|
|
||||||
top_p=1,
|
|
||||||
frequency_penalty=0,
|
|
||||||
presence_penalty=0,
|
|
||||||
)["choices"][0]["text"]
|
|
||||||
|
|
||||||
return response
|
|
Loading…
x
Reference in New Issue
Block a user