Oscar S
Oscar S

Reputation: 1

SentenceTransformerEmbeddingFunction doesn't work inside Web2py

the next code works right when I run from python line command or from single python module, but when I run from default.py controller in web2py doesn't work `

from chromadb.utils import embedding_functions

def chat2(): 
    embedding_model = "thenlper/gte-large"
    print("init_chat_ollama_query pto 3")

    embeddings = embedding_functions.SentenceTransformerEmbeddingFunction(model_name=embedding_model)

    print("init_chat_ollama_query pto 4")

    return ("funciona")`

The web2py ticket is:

Error ticket for "widchat"
Ticket ID

127.0.0.1.2024-09-20.12-40-26.5c8ff9ff-0040-47e5-8698-a897be2bcd7d
<class 'NameError'> name '_C' is not defined
Versión
web2py™     Version 2.17.1-stable+timestamp.2018.08.05.17.57.00
Rastreo

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.

    

Traceback (most recent call last):
  File "C:\tutor.ia.produ\gluon\restricted.py", line 225, in restricted
    exec(ccode, environment)
NameError: name '_C' is not defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\tutor.ia.produ\gluon\restricted.py", line 144, in __init__
    self.traceback = traceback.format_exc()
AttributeError: 'NoneType' object has no attribute 'strip'

In file: C:\tutor.ia.produ\applications\widchat\controllers/def.py

1.

    

<code object <module> at 0x0000021E803BFB30, file "C:\tutor.ia.produ\applications\widchat\controllers/def.py", line 1>

The version of chromadb is 0.5.7 and the version of python is 3.8.10

The same code outside from web2py works right

Can anybody help me please? I don't know to do, thanks

Test in python command line:

C:\Python\Python38>python
Python 3.8.10 (tags/v3.8.10:3d8993a, May  3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import chromadb
>>> from chromadb.utils import embedding_functions
>>> embedding_model = "thenlper/gte-large"
>>> embeddings = embedding_functions.SentenceTransformerEmbeddingFunction(model_name=embedding_model)
>>> embeddings = embedding_functions.SentenceTransformerEmbeddingFunction(model_name=embedding_model)
>>> embedding_functions.SentenceTransformerEmbeddingFunction(model_name=embedding_model)
<chromadb.utils.embedding_functions.SentenceTransformerEmbeddingFunction object at 0x00000192CE386100>

Runs right

Upvotes: 0

Views: 41

Answers (0)

Related Questions