From 4fb51cb0cdc0dbd9baf5247750ff1eac2f01dae3 Mon Sep 17 00:00:00 2001 From: erhant Date: Sun, 17 Nov 2024 21:27:51 +0700 Subject: [PATCH] small fix, export message input --- src/lib.rs | 2 ++ src/program/workflow.rs | 4 +-- tests/test_workflows/search.json | 42 +++++++++++++++++++++++--------- 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index f5012ff..8da3803 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -36,3 +36,5 @@ pub use program::{ models::{Model, ModelProvider}, workflow::Workflow, }; + +pub use program::atomics::{MessageInput, Task}; diff --git a/src/program/workflow.rs b/src/program/workflow.rs index 17ff79a..b500c27 100644 --- a/src/program/workflow.rs +++ b/src/program/workflow.rs @@ -101,8 +101,8 @@ impl Workflow { &self.tasks } /// Returns a mutable reference to the tasks of the workflow. - pub fn get_tasks_mut(&mut self) -> &Vec { - &self.tasks + pub fn get_tasks_mut(&mut self) -> &mut Vec { + &mut self.tasks } /// Returns a reference to the steps of the workflow. pub fn get_workflow(&self) -> &Vec { diff --git a/tests/test_workflows/search.json b/tests/test_workflows/search.json index dc0a0a2..b3a6564 100644 --- a/tests/test_workflows/search.json +++ b/tests/test_workflows/search.json @@ -11,7 +11,12 @@ "id": "A", "name": "Web Search Query", "description": "Write a web search query to collect useful information for the given question", - "messages": [{"role": "user", "content":"You are tasked with generating a single search query to gather useful information for answering a given question. Your goal is to create a concise, clear, and creative query that avoids repeating previously asked questions.\n\nHere is the query you need to address:\n\n{{query}}\n\n\nHere are the previous questions that have been asked:\n\n{{history}}\n\n\nWhen creating your search query, follow these guidelines:\n1. Analyze the given query and identify key concepts or terms.\n2. Review the previous questions to avoid repetition.\n3. Be creative in your approach, considering alternative phrasings or related concepts.\n4. Keep the query concise and clear, typically no more than 5-7 words.\n5. Focus on gathering information that will be most useful in answering the original query.\n\nProvide your search query inside tags. Do not include any explanation or additional text outside these tags."}], + "messages": [ + { + "role": "user", + "content": "You are tasked with generating a single search query to gather useful information for answering a given question. Your goal is to create a concise, clear, and creative query that avoids repeating previously asked questions.\n\nHere is the query you need to address:\n\n{{query}}\n\n\nHere are the previous questions that have been asked:\n\n{{history}}\n\n\nWhen creating your search query, follow these guidelines:\n1. Analyze the given query and identify key concepts or terms.\n2. Review the previous questions to avoid repetition.\n3. Be creative in your approach, considering alternative phrasings or related concepts.\n4. Keep the query concise and clear, typically no more than 5-7 words.\n5. Focus on gathering information that will be most useful in answering the original query.\n\nProvide your search query inside tags. Do not include any explanation or additional text outside these tags." + } + ], "inputs": [ { "name": "query", @@ -48,7 +53,7 @@ "id": "B", "name": "Web Search", "description": "Search the web with the given query", - "messages": [{"role": "user", "content": "{query}"}], + "messages": [{ "role": "user", "content": "{query}" }], "inputs": [ { "name": "query", @@ -77,7 +82,12 @@ "id": "C", "name": "Candidate Website", "description": "Pick the most useful link from web search results for the given query", - "messages": [{"role": "user", "content":"Pick the most useful URL to scrape information for Query: {query} \n\n ###Sarch Results:{web_results} \n\n Only output the selected URL: ###Selected URL:"}], + "messages": [ + { + "role": "user", + "content": "Pick the most useful URL to scrape information for Query: {query} \n\n ###Sarch Results:{web_results} \n\n Only output the selected URL: ###Selected URL:" + } + ], "inputs": [ { "name": "web_results", @@ -109,7 +119,7 @@ "id": "D", "name": "Scrape Website", "description": "Scrape the selected website", - "messages": [{"role": "user", "content":"scrape {search_url}"}], + "messages": [{ "role": "user", "content": "scrape {search_url}" }], "inputs": [ { "name": "search_url", @@ -134,7 +144,12 @@ "id": "E", "name": "Summarize Website", "description": "Summarize website content", - "messages": [{"role": "user", "content":"Answer given question completely based on following context. Don't assume anything. Use the provided information to answer the question. If context is not enough, say 'I dont know.' ###Content: {content} \n\n ###Question: {query} \n\n ###Answer:"}], + "messages": [ + { + "role": "user", + "content": "Answer given question completely based on following context. Don't assume anything. Use the provided information to answer the question. If context is not enough, say 'I dont know.' ###Content: {content} \n\n ###Question: {query} \n\n ###Answer:" + } + ], "inputs": [ { "name": "content", @@ -167,7 +182,12 @@ "id": "F", "name": "Evaluate Result", "description": "Evaluate if the result is satisfying", - "messages": [{"role": "user", "content":"Evaluate the result if it answers the query. Write 'Yes' if valid, if not 'No'.Write nothing else but strictly 'Yes'|'No'. query:{query} result:{answer}. ###Evaluation:"}], + "messages": [ + { + "role": "user", + "content": "Evaluate the result if it answers the query. Write 'Yes' if valid, if not 'No'.Write nothing else but strictly 'Yes'|'No'. query:{query} result:{answer}. ###Evaluation:" + } + ], "inputs": [ { "name": "answer", @@ -199,7 +219,7 @@ "id": "__end", "name": "end", "description": "End of the task", - "messages": [{"role": "user", "content": "End of the task"}], + "messages": [{ "role": "user", "content": "End of the task" }], "inputs": [], "operator": "end", "outputs": [] @@ -233,14 +253,14 @@ "source": "F", "target": "end", "condition": { - "input":{ - "type":"read", - "key": "final_result" + "input": { + "type": "read", + "key": "final_result" }, "expression": "Equal", "expected": "Yes", "target_if_not": "A" - } + } } ], "return_value": {