parent
42b2cd6313
commit
7ee4fe323b
@ -1,15 +0,0 @@
|
||||
from swarms import WorkerUltraUltraNode
|
||||
|
||||
# Define an objective
|
||||
objective = """
|
||||
Please make a web GUI for using HTTP API server.
|
||||
The name of it is Swarms.
|
||||
You can check the server code at ./main.py.
|
||||
The server is served on localhost:8000.
|
||||
Users should be able to write text input as 'query' and url array as 'files', and check the response.
|
||||
Users input form should be delivered in JSON format.
|
||||
I want it to have neumorphism-style. Serve it on port 4500.
|
||||
"""
|
||||
|
||||
node = WorkerUltraUltraNode(objective)
|
||||
result = node.execute()
|
@ -1,17 +0,0 @@
|
||||
from langchain.models import OpenAIChat
|
||||
from swarms import Worker
|
||||
|
||||
llm = OpenAIChat(model_name="gpt-4", openai_api_key="api-key", temperature=0.5)
|
||||
|
||||
node = Worker(
|
||||
llm=llm,
|
||||
ai_name="Optimus Prime",
|
||||
ai_role="Worker in a swarm",
|
||||
external_tools=None,
|
||||
human_in_the_loop=False,
|
||||
temperature=0.5,
|
||||
)
|
||||
|
||||
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 = node.run(task)
|
||||
print(response)
|
@ -1,15 +0,0 @@
|
||||
from swarms import worker_node
|
||||
|
||||
# Your OpenAI API key
|
||||
api_key = "sksdsds"
|
||||
|
||||
# Initialize a WorkerNode with your API key
|
||||
node = worker_node(api_key)
|
||||
|
||||
# Define an objective
|
||||
objective = "Please make a web GUI for using HTTP API server..."
|
||||
|
||||
# Run the task
|
||||
task = node.run(objective)
|
||||
|
||||
print(task)
|
@ -1,25 +0,0 @@
|
||||
import os
|
||||
from swarms.swarms.swarms import WorkerUltra
|
||||
|
||||
api_key = os.getenv("OPENAI_API_KEY")
|
||||
|
||||
# Define an objective
|
||||
objective = """
|
||||
Please make a web GUI for using HTTP API server.
|
||||
The name of it is Swarms.
|
||||
You can check the server code at ./main.py.
|
||||
The server is served on localhost:8000.
|
||||
Users should be able to write text input as 'query' and url array as 'files', and check the response.
|
||||
Users input form should be delivered in JSON format.
|
||||
I want it to have neumorphism-style. Serve it on port 4500.
|
||||
|
||||
"""
|
||||
|
||||
# Create an instance of WorkerUltra
|
||||
worker = WorkerUltra(objective, api_key)
|
||||
|
||||
# Execute the task
|
||||
result = worker.execute()
|
||||
|
||||
# Print the result
|
||||
print(result)
|
@ -0,0 +1,44 @@
|
||||
import sys
|
||||
import os
|
||||
|
||||
try:
|
||||
import PyPDF2
|
||||
except ImportError:
|
||||
print("PyPDF2 not installed. Please install it using: pip install PyPDF2")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
|
||||
def pdf_to_text(pdf_path):
|
||||
"""
|
||||
Converts a PDF file to a string of text.
|
||||
|
||||
Args:
|
||||
pdf_path (str): The path to the PDF file to be converted.
|
||||
|
||||
Returns:
|
||||
str: The text extracted from the PDF.
|
||||
|
||||
Raises:
|
||||
FileNotFoundError: If the PDF file is not found at the specified path.
|
||||
Exception: If there is an error in reading the PDF file.
|
||||
"""
|
||||
try:
|
||||
# Open the PDF file
|
||||
with open(pdf_path, 'rb') as file:
|
||||
pdf_reader = PyPDF2.PdfReader(file)
|
||||
text = ""
|
||||
|
||||
# Iterate through each page and extract text
|
||||
for page in pdf_reader.pages:
|
||||
text += page.extract_text() + "\n"
|
||||
|
||||
return text
|
||||
except FileNotFoundError:
|
||||
raise FileNotFoundError(f"The file at {pdf_path} was not found.")
|
||||
except Exception as e:
|
||||
raise Exception(f"An error occurred while reading the PDF file: {e}")
|
||||
|
||||
# Example usage
|
||||
# text = pdf_to_text("test.pdf")
|
||||
# print(text)
|
Loading…
Reference in new issue