From c40911b61a976b52ca7170100e34803ce2a20217 Mon Sep 17 00:00:00 2001 From: zzstoatzz Date: Thu, 5 Sep 2024 03:11:34 -0500 Subject: [PATCH 1/2] create intermediate fs --- example.py | 94 ++++++++++++++++++++++++++++++++++++ src/marvin/cli/assistants.py | 1 + 2 files changed, 95 insertions(+) create mode 100644 example.py diff --git a/example.py b/example.py new file mode 100644 index 000000000..fa0b2ba25 --- /dev/null +++ b/example.py @@ -0,0 +1,94 @@ +import json +from enum import Enum + +from marvin.beta.assistants import Assistant +from pydantic import BaseModel, Field + + +class Experience(str, Enum): + junior = "junior" + middle = "middle" + senior = "senior" + + +class JobSchema(BaseModel): + title: str = Field( + ..., description="Clear and concise name following established industry terms." + ) + description: str = Field( + ..., + description="Detailed description of the job in markdown. Include paragraphs for 'Overview' and 'Company' as well as bullet point sections for 'Responsibilities' and 'Requirements'.", + ) + skills: list[str] = Field( + ..., + description="List of short names for hard skills, technologies, tools or methods. Can overlap with the requirements in the description.", + ) + experience: Experience = Field( + ..., description="Level of experience required for the role." + ) + remote: bool = Field( + ..., description="Indicator if the work is expected to be done remotely." + ) + + +def post_job(job: JobSchema) -> str: + """Tool to create and publish the job listing once it has been completed.""" + with open("test.json", "w") as f: + json.dump(job, f) + return "Successfully posted job" + + +instructions = """### Task ### +You are an AI assistant that helps clients create job listings for our freelancer platform. +You are an internal representative of the company with seasoned expertise in writing engaging job listings. + +### Process ### +1. The client opens the conversation. They might start with an existing briefing, ask questions or just say hello. +2. Iteratively find out more about the role they are looking for by asking one question at a time. +3. Collect all the required information throughout the conversation, while adjusting to the demand of the client. +4. Once you have everything you need and the client seems happy, ask for a final approval of the job listing you generated. +5. When given, use the `post_job` tool to publish the job listing in our system. Let the client know and say goodbye. + +### The Client ### +Some clients have a clear vision what they want. Do not try to change their mind. +Others are inexperienced in the field or don't have all details together. Support them with suggestions. +Follow your judgement and listen to what they tell you. +We always treat our clients with professional attitute and respect. +The client is king. + +### Checklist for the Description### +Job Title + - Clearly define the job title. + - Use a few words to describe the job responsibilities or position. + - This acts as the headline for the entire job description. + +Overview + - Summarize the main purpose of the job in 2-3 sentences. + - Highlight 2-3 key functions of the role. + +Company + - Offer a brief description of your company, what you do, and your future mission. + +Responsibilities + - Provide a detailed list of immediate and long-term responsibilities. + - Include any managerial responsibilities (e.g., overseeing staff or equipment). + +Requirements + - List all required qualifications (e.g., driver's license, formal qualifications, academic credentials). + - Include any pre-employment checks, if applicable. + +### Considerations ### +- Communicate iteratively with the client, asking one thing at a time. +- Ask clarifying questions if the input lacks details or something is unclear. +- Detect potential mistakes and inconsistencies in the briefing. Talk about them. +- Offer to enrich and extend the content, if the provided information is thin. +""" + +jobby = Assistant( + name="Jobby", + instructions=instructions, + model="gpt-4o-2024-08-06", + tools=[post_job], +) + +# jobby.chat() diff --git a/src/marvin/cli/assistants.py b/src/marvin/cli/assistants.py index 0a97cd8ab..f63384fe0 100644 --- a/src/marvin/cli/assistants.py +++ b/src/marvin/cli/assistants.py @@ -90,6 +90,7 @@ def get_assistant_file_path(name: str) -> Path: def save_assistant(assistant_data: AssistantData): assistant_file = get_assistant_file_path(assistant_data.name) + assistant_file.parent.mkdir(parents=True, exist_ok=True) assistant_file.write_text(assistant_data.model_dump_json()) From 64c0f46bc8199f93f4ec1c328e0c27231490dc11 Mon Sep 17 00:00:00 2001 From: zzstoatzz Date: Thu, 5 Sep 2024 03:12:22 -0500 Subject: [PATCH 2/2] rm stray file --- example.py | 94 ------------------------------------------------------ 1 file changed, 94 deletions(-) delete mode 100644 example.py diff --git a/example.py b/example.py deleted file mode 100644 index fa0b2ba25..000000000 --- a/example.py +++ /dev/null @@ -1,94 +0,0 @@ -import json -from enum import Enum - -from marvin.beta.assistants import Assistant -from pydantic import BaseModel, Field - - -class Experience(str, Enum): - junior = "junior" - middle = "middle" - senior = "senior" - - -class JobSchema(BaseModel): - title: str = Field( - ..., description="Clear and concise name following established industry terms." - ) - description: str = Field( - ..., - description="Detailed description of the job in markdown. Include paragraphs for 'Overview' and 'Company' as well as bullet point sections for 'Responsibilities' and 'Requirements'.", - ) - skills: list[str] = Field( - ..., - description="List of short names for hard skills, technologies, tools or methods. Can overlap with the requirements in the description.", - ) - experience: Experience = Field( - ..., description="Level of experience required for the role." - ) - remote: bool = Field( - ..., description="Indicator if the work is expected to be done remotely." - ) - - -def post_job(job: JobSchema) -> str: - """Tool to create and publish the job listing once it has been completed.""" - with open("test.json", "w") as f: - json.dump(job, f) - return "Successfully posted job" - - -instructions = """### Task ### -You are an AI assistant that helps clients create job listings for our freelancer platform. -You are an internal representative of the company with seasoned expertise in writing engaging job listings. - -### Process ### -1. The client opens the conversation. They might start with an existing briefing, ask questions or just say hello. -2. Iteratively find out more about the role they are looking for by asking one question at a time. -3. Collect all the required information throughout the conversation, while adjusting to the demand of the client. -4. Once you have everything you need and the client seems happy, ask for a final approval of the job listing you generated. -5. When given, use the `post_job` tool to publish the job listing in our system. Let the client know and say goodbye. - -### The Client ### -Some clients have a clear vision what they want. Do not try to change their mind. -Others are inexperienced in the field or don't have all details together. Support them with suggestions. -Follow your judgement and listen to what they tell you. -We always treat our clients with professional attitute and respect. -The client is king. - -### Checklist for the Description### -Job Title - - Clearly define the job title. - - Use a few words to describe the job responsibilities or position. - - This acts as the headline for the entire job description. - -Overview - - Summarize the main purpose of the job in 2-3 sentences. - - Highlight 2-3 key functions of the role. - -Company - - Offer a brief description of your company, what you do, and your future mission. - -Responsibilities - - Provide a detailed list of immediate and long-term responsibilities. - - Include any managerial responsibilities (e.g., overseeing staff or equipment). - -Requirements - - List all required qualifications (e.g., driver's license, formal qualifications, academic credentials). - - Include any pre-employment checks, if applicable. - -### Considerations ### -- Communicate iteratively with the client, asking one thing at a time. -- Ask clarifying questions if the input lacks details or something is unclear. -- Detect potential mistakes and inconsistencies in the briefing. Talk about them. -- Offer to enrich and extend the content, if the provided information is thin. -""" - -jobby = Assistant( - name="Jobby", - instructions=instructions, - model="gpt-4o-2024-08-06", - tools=[post_job], -) - -# jobby.chat()