parent
							
								
									cbf4a07d4a
								
							
						
					
					
						commit
						a16a96bfb8
					
				| @ -0,0 +1,32 @@ | |||||||
|  | from swarms.models.bing_chat import BingChat | ||||||
|  | from swarms.workers.worker import Worker | ||||||
|  | from swarms.tools.autogpt import EdgeGPTTool, tool | ||||||
|  | from swarms.models import OpenAIChat | ||||||
|  | import os | ||||||
|  | 
 | ||||||
|  | api_key = os.getenv("OPENAI_API_KEY") | ||||||
|  | 
 | ||||||
|  | # Initialize the EdgeGPTModel | ||||||
|  | edgegpt = BingChat(cookies_path="./cookies.txt") | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @tool | ||||||
|  | def edgegpt(task: str = None): | ||||||
|  |     """A tool to run infrence on the EdgeGPT Model""" | ||||||
|  |     return EdgeGPTTool.run(task) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | # Initialize the language model, | ||||||
|  | # This model can be swapped out with Anthropic, ETC, Huggingface Models like Mistral, ETC | ||||||
|  | llm = OpenAIChat( | ||||||
|  |     openai_api_key=api_key, | ||||||
|  |     temperature=0.5, | ||||||
|  | ) | ||||||
|  | 
 | ||||||
|  | # Initialize the Worker with the custom tool | ||||||
|  | worker = Worker(llm=llm, ai_name="EdgeGPT Worker", external_tools=[edgegpt]) | ||||||
|  | 
 | ||||||
|  | # Use the worker to process a task | ||||||
|  | task = "Hello, my name is ChatGPT" | ||||||
|  | response = worker.run(task) | ||||||
|  | print(response) | ||||||
| @ -0,0 +1,14 @@ | |||||||
|  | import os | ||||||
|  | from swarms.models.bing_chat import BingChat | ||||||
|  | from apps.discord import Bot | ||||||
|  | from dotenv import load_dotenv | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | # Initialize the EdgeGPTModel | ||||||
|  | cookie = os.environ.get("BING_COOKIE") | ||||||
|  | auth = os.environ.get("AUTH_COOKIE") | ||||||
|  | bing = BingChat(cookies_path="./cookies.txt", bing_cookie=cookie, auth_cookie=auth) | ||||||
|  | 
 | ||||||
|  | bot = Bot(llm=bing, cookie=cookie, auth=auth) | ||||||
|  | bot.generate_image(imggen=bing.create_img()) | ||||||
|  | bot.send_text(use_agent=False) | ||||||
| @ -1,32 +1,19 @@ | |||||||
| from swarms.models.bing_chat import BingChat |  | ||||||
| from swarms.workers.worker import Worker |  | ||||||
| from swarms.tools.autogpt import EdgeGPTTool, tool |  | ||||||
| from swarms.models import OpenAIChat |  | ||||||
| import os | import os | ||||||
|  | from swarms.models.bing_chat import BingChat | ||||||
|  | from dotenv import load_dotenv | ||||||
| 
 | 
 | ||||||
| api_key = os.getenv("OPENAI_API_KEY") | load_dotenv() | ||||||
| 
 | 
 | ||||||
| # Initialize the EdgeGPTModel | # Initialize the EdgeGPTModel | ||||||
| edgegpt = BingChat(cookies_path="./cookies.txt") | edgegpt = BingChat(cookies_path="./cookies.json") | ||||||
| 
 | cookie = os.environ.get("BING_COOKIE") | ||||||
| 
 | auth = os.environ.get("AUTH_COOKIE") | ||||||
| @tool |  | ||||||
| def edgegpt(task: str = None): |  | ||||||
|     """A tool to run infrence on the EdgeGPT Model""" |  | ||||||
|     return EdgeGPTTool.run(task) |  | ||||||
| 
 | 
 | ||||||
|  | # Use the worker to process a task | ||||||
|  | task = "hi" | ||||||
|  | # img_task = "Sunset over mountains" | ||||||
| 
 | 
 | ||||||
| # Initialize the language model, | response = edgegpt(task) | ||||||
| # This model can be swapped out with Anthropic, ETC, Huggingface Models like Mistral, ETC | # response = edgegpt.create_img(auth_cookie=cookie,auth_cookie_SRCHHPGUSR=auth,prompt=img_task) | ||||||
| llm = OpenAIChat( |  | ||||||
|     openai_api_key=api_key, |  | ||||||
|     temperature=0.5, |  | ||||||
| ) |  | ||||||
| 
 |  | ||||||
| # Initialize the Worker with the custom tool |  | ||||||
| worker = Worker(llm=llm, ai_name="EdgeGPT Worker", external_tools=[edgegpt]) |  | ||||||
| 
 | 
 | ||||||
| # Use the worker to process a task |  | ||||||
| task = "Hello, my name is ChatGPT" |  | ||||||
| response = worker.run(task) |  | ||||||
| print(response) | print(response) | ||||||
|  | |||||||
					Loading…
					
					
				
		Reference in new issue