Skip to content

Commit

Permalink
pass the server name to reach remote deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
masci committed Apr 10, 2024
1 parent 50599c3 commit ad5a10c
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 9 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 4 additions & 2 deletions src/hayhooks/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions src/hayhooks/cli/deploy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')}")
Expand Down
5 changes: 3 additions & 2 deletions src/hayhooks/cli/status/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/hayhooks/cli/undeploy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')}")
Expand Down
50 changes: 50 additions & 0 deletions tests/test_files/chat_with_website.yaml
Original file line number Diff line number Diff line change
@@ -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: {}

0 comments on commit ad5a10c

Please sign in to comment.