feat: Add model example

pull/65/head
Zack 1 year ago
parent 0755c6fe1b
commit f3a238294c

@ -0,0 +1,25 @@
import os
from dotenv import load_dotenv
from swarms.models.revgpt import RevChatGPTModel
from swarms.workers.worker import Worker
load_dotenv()
config = {
"model": os.getenv("REVGPT_MODEL"),
"plugin_ids": [os.getenv("REVGPT_PLUGIN_IDS")],
"disable_history": os.getenv("REVGPT_DISABLE_HISTORY") == "True",
"PUID": os.getenv("REVGPT_PUID"),
"unverified_plugin_domains": [os.getenv("REVGPT_UNVERIFIED_PLUGIN_DOMAINS")]
}
llm = RevChatGPTModel(access_token=os.getenv("ACCESS_TOKEN"), **config)
worker = Worker(
ai_name="Optimus Prime",
llm=llm
)
task = "What were the winning boston marathon times for the past 5 years (ending in 2022)? Generate a table of the year, name, country of origin, and times."
response = worker.run(task)
print(response)

@ -1,8 +1,12 @@
import os
import sys
from dotenv import load_dotenv
from swarms.models.revgpt import RevChatGPTModel
from swarms.workers.worker import Worker
root_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(root_dir)
load_dotenv()
config = {
@ -13,13 +17,12 @@ config = {
"unverified_plugin_domains": [os.getenv("REVGPT_UNVERIFIED_PLUGIN_DOMAINS")]
}
llm = RevChatGPTModel(access_token=os.getenv("ACCESS_TOKEN"), **config)
# For v1 model
# model = RevChatGPTModel(access_token=os.getenv("ACCESS_TOKEN"), **config)
worker = Worker(
ai_name="Optimus Prime",
llm=llm
)
# For v3 model
model = RevChatGPTModel(access_token=os.getenv("OPENAI_API_KEY"), **config)
task = "What were the winning boston marathon times for the past 5 years (ending in 2022)? Generate a table of the year, name, country of origin, and times."
response = worker.run(task)
task = "Write a cli snake game"
response = model.run(task)
print(response)

Loading…
Cancel
Save