diff --git a/README.md b/README.md index 946d2e6..8f86b2c 100644 --- a/README.md +++ b/README.md @@ -167,7 +167,6 @@ $ docker run --rm -p 1416:1416 -v $PWD/pipelines:/opt/pipelines "deepset/hayhook At this stage Hayhooks is just a prototype, the natural next steps would be: - Improve server configuration management (easy) -- Add CLI configuration profiles, so it's easy to address different servers (easy) - Manage pipeline dependencies: one way could be adding the required packages in the pipeline's metadata and let the server handle installation (complex) diff --git a/src/hayhooks/cli/__init__.py b/src/hayhooks/cli/__init__.py index d4cfc97..537dfea 100644 --- a/src/hayhooks/cli/__init__.py +++ b/src/hayhooks/cli/__init__.py @@ -11,8 +11,10 @@ @click.group(context_settings={"help_option_names": ["-h", "--help"]}, invoke_without_command=True) @click.version_option(prog_name="Hayhooks") -def hayhooks(): - pass +@click.option('--server', default="http://localhost:1416") +@click.pass_context +def hayhooks(ctx, server): + ctx.obj = server hayhooks.add_command(run) diff --git a/src/hayhooks/cli/deploy/__init__.py b/src/hayhooks/cli/deploy/__init__.py index 7ce0fd5..851f056 100644 --- a/src/hayhooks/cli/deploy/__init__.py +++ b/src/hayhooks/cli/deploy/__init__.py @@ -5,12 +5,13 @@ @click.command() +@click.pass_obj @click.option('-n', '--name') @click.argument('pipeline_file', type=click.File('r')) -def deploy(name, pipeline_file): +def deploy(server, name, pipeline_file): if name is None: name = Path(pipeline_file.name).stem - resp = requests.post("http://localhost:1416/deploy", json={"name": name, "source_code": str(pipeline_file.read())}) + resp = requests.post(f"{server}/deploy", json={"name": name, "source_code": str(pipeline_file.read())}) if resp.status_code >= 400: click.echo(f"Error deploying pipeline: {resp.json().get('detail')}") diff --git a/src/hayhooks/cli/status/__init__.py b/src/hayhooks/cli/status/__init__.py index f5b95df..d12f05b 100644 --- a/src/hayhooks/cli/status/__init__.py +++ b/src/hayhooks/cli/status/__init__.py @@ -4,9 +4,10 @@ @click.command() -def status(): +@click.pass_obj +def status(server): try: - r = requests.get("http://localhost:1416/status") + r = requests.get(f"{server}/status") except ConnectionError: click.echo("Hayhooks server is not responding. To start one, run `hayooks run`") return diff --git a/src/hayhooks/cli/undeploy/__init__.py b/src/hayhooks/cli/undeploy/__init__.py index 8558a17..9957d7a 100644 --- a/src/hayhooks/cli/undeploy/__init__.py +++ b/src/hayhooks/cli/undeploy/__init__.py @@ -6,10 +6,11 @@ @click.command() +@click.pass_obj @click.argument('pipeline_name') -def undeploy(pipeline_name): +def undeploy(server, pipeline_name): try: - resp = requests.post(f"http://localhost:1416/undeploy/{pipeline_name}") + resp = requests.post(f"{server}/undeploy/{pipeline_name}") if resp.status_code >= 400: click.echo(f"Cannot undeploy pipeline: {resp.json().get('detail')}") diff --git a/tests/test_files/chat_with_website.yaml b/tests/test_files/chat_with_website.yaml new file mode 100644 index 0000000..1cb3869 --- /dev/null +++ b/tests/test_files/chat_with_website.yaml @@ -0,0 +1,50 @@ +components: + converter: + init_parameters: + extractor_type: DefaultExtractor + type: haystack.components.converters.html.HTMLToDocument + + fetcher: + init_parameters: + raise_on_failure: true + retry_attempts: 2 + timeout: 3 + user_agents: + - haystack/LinkContentFetcher/2.0.0b8 + type: haystack.components.fetchers.link_content.LinkContentFetcher + + llm: + init_parameters: + api_base_url: null + api_key: + env_vars: + - OPENAI_API_KEY + strict: true + type: env_var + generation_kwargs: {} + model: gpt-3.5-turbo + streaming_callback: null + system_prompt: null + type: haystack.components.generators.openai.OpenAIGenerator + + prompt: + init_parameters: + template: | + "According to the contents of this website: + {% for document in documents %} + {{document.content}} + {% endfor %} + Answer the given question: {{query}} + Answer: + " + type: haystack.components.builders.prompt_builder.PromptBuilder + +connections: +- receiver: converter.sources + sender: fetcher.streams +- receiver: prompt.documents + sender: converter.documents +- receiver: llm.prompt + sender: prompt.prompt + +metadata: {}