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

chatbot-rag-app: removes unnecessary parts of Docker build #406

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

codefromthecrypt
Copy link
Collaborator

@xrmx noted that the docker entrypoint workaround might not be needed since a few versions back.

I tried to verify this by running chatbot-rag-app in docker from source like this docker compose up --build --force-recreate and while I didn't seem much spam in the first stage of ingest, it seems still a bug later when you start clicking

Once this resolves in EDOT or upstream, we can try again:

 ✔ Container create-index  Recreated                                                                                                                                     0.1s 
 ✔ Container api-frontend  Recreated                                                                                                                                     0.0s 
Attaching to api-frontend, create-index
create-index  | /usr/local/lib/python3.12/site-packages/opentelemetry/instrumentation/elasticsearch/__init__.py:213: Warning: Instrumentation disabled, relying on elasticsearch native OTel support, see https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/elasticsearch/elasticsearch.html
create-index  |   warnings.warn(
create-index  | ".elser_model_2" model is ready
create-index  | Loading data from $/app/data/data.json
create-index  | Loaded 15 documents
create-index  | Split 15 documents into 26 chunks
create-index  | Creating Elasticsearch sparse vector store for http://localhost:9200
create-index  | Adding documents to index workplace-app-docs
create-index  | Documents added to index workplace-app-docs
create-index exited with code 0
api-frontend  |  * Serving Flask app 'app'
api-frontend  |  * Debug mode: off
api-frontend  | WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
api-frontend  |  * Running on all addresses (0.0.0.0)
api-frontend  |  * Running on http://127.0.0.1:4000
api-frontend  |  * Running on http://172.24.0.2:4000
api-frontend  | Press CTRL+C to quit
api-frontend  | 172.24.0.1 - - [25/Feb/2025 06:10:29] "GET / HTTP/1.1" 304 -
api-frontend  | 172.24.0.1 - - [25/Feb/2025 06:10:29] "GET /static/js/main.065b97c9.js HTTP/1.1" 304 -
api-frontend  | 172.24.0.1 - - [25/Feb/2025 06:10:29] "GET /static/css/main.ca9c35c3.css HTTP/1.1" 304 -
api-frontend  | 172.24.0.1 - - [25/Feb/2025 06:10:29] "GET /manifest.json HTTP/1.1" 304 -
api-frontend  | 172.24.0.1 - - [25/Feb/2025 06:10:29] "GET /logo192.png HTTP/1.1" 304 -
api-frontend  | 172.24.0.1 - - [25/Feb/2025 06:10:30] "POST /api/chat HTTP/1.1" 200 -
api-frontend  | /usr/local/lib/python3.12/site-packages/opentelemetry/instrumentation/elasticsearch/__init__.py:213: Warning: Instrumentation disabled, relying on elasticsearch native OTel support, see https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/elasticsearch/elasticsearch.html
api-frontend  |   warnings.warn(
api-frontend  | /usr/local/lib/python3.12/site-packages/opentelemetry/instrumentation/elasticsearch/__init__.py:213: Warning: Instrumentation disabled, relying on elasticsearch native OTel support, see https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/elasticsearch/elasticsearch.html
api-frontend  |   warnings.warn(
api-frontend  | /usr/local/lib/python3.12/site-packages/langchain_elasticsearch/_sync/vectorstores.py:411: ElasticsearchWarning: text_expansion is deprecated. Use sparse_vector instead.
api-frontend  |   hits = self._store.search(
api-frontend  | Error on request:
api-frontend  | Traceback (most recent call last):
api-frontend  |   File "/usr/local/lib/python3.12/site-packages/opentelemetry/instrumentation/openai/wrappers.py", line 118, in __next__
api-frontend  |     chunk = next(self.stream)
api-frontend  |             ^^^^^^^^^^^^^^^^^
api-frontend  |   File "/usr/local/lib/python3.12/site-packages/openai/_streaming.py", line 43, in __next__
api-frontend  |     return self._iterator.__next__()
api-frontend  |            ^^^^^^^^^^^^^^^^^^^^^^^^^
api-frontend  | StopIteration
api-frontend  | 
api-frontend  | During handling of the above exception, another exception occurred:
api-frontend  | 
api-frontend  | Traceback (most recent call last):
api-frontend  |   File "/usr/local/lib/python3.12/site-packages/langchain_openai/chat_models/base.py", line 737, in _stream
api-frontend  |     for chunk in response:
api-frontend  |                  ^^^^^^^^^
api-frontend  |   File "/usr/local/lib/python3.12/site-packages/opentelemetry/instrumentation/openai/wrappers.py", line 122, in __next__
api-frontend  |     self.end(exc)
api-frontend  |   File "/usr/local/lib/python3.12/site-packages/opentelemetry/instrumentation/openai/wrappers.py", line 78, in end
api-frontend  |     _record_operation_duration_metric(self.operation_duration_metric, self.span, self.start_time)
api-frontend  |   File "/usr/local/lib/python3.12/site-packages/opentelemetry/instrumentation/openai/helpers.py", line 212, in _record_operation_duration_metric
api-frontend  |     operation_duration_metric_attrs = _get_attributes_if_set(
api-frontend  |                                       ^^^^^^^^^^^^^^^^^^^^^^^
api-frontend  |   File "/usr/local/lib/python3.12/site-packages/opentelemetry/instrumentation/openai/helpers.py", line 189, in _get_attributes_if_set
api-frontend  |     attributes = span.attributes
api-frontend  |                  ^^^^^^^^^^^^^^^
api-frontend  | AttributeError: 'NonRecordingSpan' object has no attribute 'attributes'. Did you mean: 'set_attributes'?
api-frontend  | 
api-frontend  | During handling of the above exception, another exception occurred:
api-frontend  | 
api-frontend  | Traceback (most recent call last):
api-frontend  |   File "/usr/local/lib/python3.12/site-packages/werkzeug/serving.py", line 370, in run_wsgi
api-frontend  |     execute(self.server.app)
api-frontend  |   File "/usr/local/lib/python3.12/site-packages/werkzeug/serving.py", line 333, in execute
api-frontend  |     for data in application_iter:
api-frontend  |                 ^^^^^^^^^^^^^^^^^
api-frontend  |   File "/usr/local/lib/python3.12/site-packages/werkzeug/wsgi.py", line 256, in __next__
api-frontend  |     return self._next()
api-frontend  |            ^^^^^^^^^^^^
api-frontend  |   File "/usr/local/lib/python3.12/site-packages/werkzeug/wrappers/response.py", line 32, in _iter_encoded
api-frontend  |     for item in iterable:
api-frontend  |                 ^^^^^^^^^
api-frontend  |   File "/usr/local/lib/python3.12/site-packages/flask/helpers.py", line 125, in generator
api-frontend  |     yield from gen
api-frontend  |   File "/app/api/chat.py", line 78, in ask_question
api-frontend  |     for chunk in llm.stream(qa_prompt):
api-frontend  |                  ^^^^^^^^^^^^^^^^^^^^^^
api-frontend  |   File "/usr/local/lib/python3.12/site-packages/langchain_core/language_models/chat_models.py", line 415, in stream
api-frontend  |     for chunk in self._stream(messages, stop=stop, **kwargs):
api-frontend  |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
api-frontend  |   File "/usr/local/lib/python3.12/site-packages/langchain_openai/chat_models/base.py", line 735, in _stream
api-frontend  |     with context_manager as response:
api-frontend  |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
api-frontend  |   File "/usr/local/lib/python3.12/site-packages/opentelemetry/instrumentation/openai/wrappers.py", line 108, in __exit__
api-frontend  |     self.end(exc_value)
api-frontend  |   File "/usr/local/lib/python3.12/site-packages/opentelemetry/instrumentation/openai/wrappers.py", line 70, in end
api-frontend  |     _record_operation_duration_metric(self.operation_duration_metric, self.span, self.start_time)
api-frontend  |   File "/usr/local/lib/python3.12/site-packages/opentelemetry/instrumentation/openai/helpers.py", line 212, in _record_operation_duration_metric
api-frontend  |     operation_duration_metric_attrs = _get_attributes_if_set(
api-frontend  |                                       ^^^^^^^^^^^^^^^^^^^^^^^
api-frontend  |   File "/usr/local/lib/python3.12/site-packages/opentelemetry/instrumentation/openai/helpers.py", line 189, in _get_attributes_if_set
api-frontend  |     attributes = span.attributes
api-frontend  |                  ^^^^^^^^^^^^^^^
api-frontend  | AttributeError: 'NonRecordingSpan' object has no attribute 'attributes'. Did you mean: 'set_attributes'?
api-frontend  | 172.24.0.1 - - [25/Feb/2025 06:10:35] "POST /api/chat HTTP/1.1" 200 -
--snip--

While I was at it, I removed unnecessary packages from the docker image as they are distracting. Usually, we have some packages because some python package has a system dep, but that's not the case here.

Finally, I bumped requirements to latest since here already.

@codefromthecrypt
Copy link
Collaborator Author

moved the parts not about the entrypoint to this PR meanwhile #407

@codefromthecrypt
Copy link
Collaborator Author

when elastic/elastic-otel-python-instrumentations#54 is released, we should be good to go here

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.

1 participant