Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#11 Add experimental frontend #12

Merged
merged 8 commits into from
Jun 3, 2024
Merged

#11 Add experimental frontend #12

merged 8 commits into from
Jun 3, 2024

Conversation

sighmon
Copy link
Contributor

@sighmon sighmon commented May 22, 2024

Resolves #11

Let's see if we can work out an interesting interface for our collection chat.

Acceptance Criteria

  • Add a Jinja2 template for the frontend
  • Add options for visitors to pre-select a curated question
  • Add Seb's language model assisted feedback on the search results

Relevant design files

  • None

Testing instructions

  1. Add the ElevenLabs API key to your config.env from 1Password: ElevenLabs API Key
  2. Re-build your server: make build
  3. Visit the home page with json=false: http://localhost:8000/?json=false
  4. Tap Seb's summary to hear him talk about the search results with an anecdote about them

Copy link

@sam-s-maher sam-s-maher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, looks good

@rubyquaildesign
Copy link

What model(s) should I be using for this @sighmon?

@sighmon
Copy link
Contributor Author

sighmon commented Jun 3, 2024

@rubyquaildesign I'd recommend OpenAI which is the default, so unset your MODEL environment variable.

@rubyquaildesign
Copy link

@rubyquaildesign I'd recommend OpenAI which is the default, so unset your MODEL environment variable.

This gives me a fun little error here when trying to ask a question

chat  | INFO:     192.168.65.1:28050 - "GET /?query=Ask+me+a+question&json=false HTTP/1.1" 500 Internal Server Error
chat  | ERROR:    Exception in ASGI application
chat  | Traceback (most recent call last):
chat  |   File "/usr/local/lib/python3.11/site-packages/urllib3/connection.py", line 198, in _new_conn
chat  |     sock = connection.create_connection(
chat  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
chat  |   File "/usr/local/lib/python3.11/site-packages/urllib3/util/connection.py", line 85, in create_connection
chat  |     raise err
chat  |   File "/usr/local/lib/python3.11/site-packages/urllib3/util/connection.py", line 73, in create_connection
chat  |     sock.connect(sa)
chat  | ConnectionRefusedError: [Errno 111] Connection refused
chat  |
chat  | The above exception was the direct cause of the following exception:
chat  |
chat  | Traceback (most recent call last):
chat  |   File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 793, in urlopen
chat  |     response = self._make_request(
chat  |                ^^^^^^^^^^^^^^^^^^^
chat  |   File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 496, in _make_request
chat  |     conn.request(
chat  |   File "/usr/local/lib/python3.11/site-packages/urllib3/connection.py", line 400, in request
chat  |     self.endheaders()
chat  |   File "/usr/local/lib/python3.11/http/client.py", line 1298, in endheaders
chat  |     self._send_output(message_body, encode_chunked=encode_chunked)
chat  |   File "/usr/local/lib/python3.11/http/client.py", line 1058, in _send_output
chat  |     self.send(msg)
chat  |   File "/usr/local/lib/python3.11/http/client.py", line 996, in send
chat  |     self.connect()
chat  |   File "/usr/local/lib/python3.11/site-packages/urllib3/connection.py", line 238, in connect
chat  |     self.sock = self._new_conn()
chat  |                 ^^^^^^^^^^^^^^^^
chat  |   File "/usr/local/lib/python3.11/site-packages/urllib3/connection.py", line 213, in _new_conn
chat  |     raise NewConnectionError(
chat  | urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0xffff8dd85750>: Failed to establish a new connection: [Errno 111] Connection refused
chat  |
chat  | The above exception was the direct cause of the following exception:
chat  |
chat  | Traceback (most recent call last):
chat  |   File "/usr/local/lib/python3.11/site-packages/requests/adapters.py", line 667, in send
chat  |     resp = conn.urlopen(
chat  |            ^^^^^^^^^^^^^
chat  |   File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 847, in urlopen
chat  |     retries = retries.increment(
chat  |               ^^^^^^^^^^^^^^^^^^
chat  |   File "/usr/local/lib/python3.11/site-packages/urllib3/util/retry.py", line 515, in increment
chat  |     raise MaxRetryError(_pool, url, reason) from reason  # type: ignore[arg-type]
chat  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
chat  | urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=11434): Max retries exceeded with url: /api/embeddings (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xffff8dd85750>: Failed to establish a new connection: [Errno 111] Connection refused'))
chat  |
chat  | During handling of the above exception, another exception occurred:
chat  |
chat  | Traceback (most recent call last):
chat  |   File "/usr/local/lib/python3.11/site-packages/langchain_community/embeddings/ollama.py", line 164, in _process_emb_response
chat  |     res = requests.post(
chat  |           ^^^^^^^^^^^^^^
chat  |   File "/usr/local/lib/python3.11/site-packages/requests/api.py", line 115, in post
chat  |     return request("post", url, data=data, json=json, **kwargs)
chat  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
chat  |   File "/usr/local/lib/python3.11/site-packages/requests/api.py", line 59, in request
chat  |     return session.request(method=method, url=url, **kwargs)
chat  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
chat  |   File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 589, in request
chat  |     resp = self.send(prep, **send_kwargs)
chat  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
chat  |   File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 703, in send
chat  |     r = adapter.send(request, **kwargs)
chat  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
chat  |   File "/usr/local/lib/python3.11/site-packages/requests/adapters.py", line 700, in send
chat  |     raise ConnectionError(e, request=request)
chat  | requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=11434): Max retries exceeded with url: /api/embeddings (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xffff8dd85750>: Failed to establish a new connection: [Errno 111] Connection refused'))
chat  |
chat  | During handling of the above exception, another exception occurred:
chat  |
chat  | Traceback (most recent call last):
chat  |   File "/usr/local/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 399, in run_asgi
chat  |     result = await app(  # type: ignore[func-returns-value]
chat  |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
chat  |   File "/usr/local/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 70, in __call__
chat  |     return await self.app(scope, receive, send)
chat  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
chat  |   File "/usr/local/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in __call__
chat  |     await super().__call__(scope, receive, send)
chat  |   File "/usr/local/lib/python3.11/site-packages/starlette/applications.py", line 123, in __call__
chat  |     await self.middleware_stack(scope, receive, send)
chat  |   File "/usr/local/lib/python3.11/site-packages/starlette/middleware/errors.py", line 186, in __call__
chat  |     raise exc
chat  |   File "/usr/local/lib/python3.11/site-packages/starlette/middleware/errors.py", line 164, in __call__
chat  |     await self.app(scope, receive, _send)
chat  |   File "/usr/local/lib/python3.11/site-packages/starlette/middleware/cors.py", line 85, in __call__
chat  |     await self.app(scope, receive, send)
chat  |   File "/usr/local/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 65, in __call__
chat  |     await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
chat  |   File "/usr/local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
chat  |     raise exc
chat  |   File "/usr/local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
chat  |     await app(scope, receive, sender)
chat  |   File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 756, in __call__
chat  |     await self.middleware_stack(scope, receive, send)
chat  |   File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 776, in app
chat  |     await route.handle(scope, receive, send)
chat  |   File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 297, in handle
chat  |     await self.app(scope, receive, send)
chat  |   File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 77, in app
chat  |     await wrap_app_handling_exceptions(app, request)(scope, receive, send)
chat  |   File "/usr/local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
chat  |     raise exc
chat  |   File "/usr/local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
chat  |     await app(scope, receive, sender)
chat  |   File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 72, in app
chat  |     response = await func(request)
chat  |                ^^^^^^^^^^^^^^^^^^^
chat  |   File "/usr/local/lib/python3.11/site-packages/fastapi/routing.py", line 278, in app
chat  |     raw_response = await run_endpoint_function(
chat  |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
chat  |   File "/usr/local/lib/python3.11/site-packages/fastapi/routing.py", line 191, in run_endpoint_function
chat  |     return await dependant.call(**values)
chat  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
chat  |   File "/code/api/server.py", line 246, in root
chat  |     results = [json_parser.loads(result.page_content) for result in retriever.invoke(query)]
chat  |                                                                     ^^^^^^^^^^^^^^^^^^^^^^^
chat  |   File "/usr/local/lib/python3.11/site-packages/langchain_core/retrievers.py", line 194, in invoke
chat  |     return self.get_relevant_documents(
chat  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
chat  |   File "/usr/local/lib/python3.11/site-packages/langchain_core/_api/deprecation.py", line 148, in warning_emitting_wrapper
chat  |     return wrapped(*args, **kwargs)
chat  |            ^^^^^^^^^^^^^^^^^^^^^^^^
chat  |   File "/usr/local/lib/python3.11/site-packages/langchain_core/retrievers.py", line 323, in get_relevant_documents
chat  |     raise e
chat  |   File "/usr/local/lib/python3.11/site-packages/langchain_core/retrievers.py", line 316, in get_relevant_documents
chat  |     result = self._get_relevant_documents(
chat  |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
chat  |   File "/usr/local/lib/python3.11/site-packages/langchain_core/vectorstores.py", line 696, in _get_relevant_documents
chat  |     docs = self.vectorstore.similarity_search(query, **self.search_kwargs)
chat  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
chat  |   File "/usr/local/lib/python3.11/site-packages/langchain_community/vectorstores/chroma.py", line 349, in similarity_search
chat  |     docs_and_scores = self.similarity_search_with_score(
chat  |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
chat  |   File "/usr/local/lib/python3.11/site-packages/langchain_community/vectorstores/chroma.py", line 438, in similarity_search_with_score
chat  |     query_embedding = self._embedding_function.embed_query(query)
chat  |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
chat  |   File "/usr/local/lib/python3.11/site-packages/langchain_community/embeddings/ollama.py", line 224, in embed_query
chat  |     embedding = self._embed([instruction_pair])[0]
chat  |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
chat  |   File "/usr/local/lib/python3.11/site-packages/langchain_community/embeddings/ollama.py", line 199, in _embed
chat  |     return [self._process_emb_response(prompt) for prompt in iter_]
chat  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
chat  |   File "/usr/local/lib/python3.11/site-packages/langchain_community/embeddings/ollama.py", line 199, in <listcomp>
chat  |     return [self._process_emb_response(prompt) for prompt in iter_]
chat  |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
chat  |   File "/usr/local/lib/python3.11/site-packages/langchain_community/embeddings/ollama.py", line 170, in _process_emb_response
chat  |     raise ValueError(f"Error raised by inference endpoint: {e}")
chat  | ValueError: Error raised by inference endpoint: HTTPConnectionPool(host='localhost', port=11434): Max retries exceeded with url: /api/embeddings (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xffff8dd85750>: Failed to establish a new connection: [Errno 111] Connection refused'))

@sighmon sighmon merged commit 73a3579 into main Jun 3, 2024
4 checks passed
@sighmon sighmon deleted the add/11-frontend branch June 3, 2024 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add experimental frontend
3 participants