Spaces:
Running
Running
from twisted.internet import reactor, defer | |
from treq import post | |
import json | |
def embeddings_run_treq(input_text, url="https://sanbo1200-jina-embeddings-v3.hf.space/api/v1/embeddings"): | |
headers = { | |
"Content-Type": "application/json" | |
} | |
data = { | |
"input": input_text, | |
"model": "jinaai/jina-embeddings-v3" | |
} | |
response = yield post( | |
url, | |
headers=headers, | |
json=data | |
) | |
content = yield response.json() | |
defer.returnValue(content) | |
def main(): | |
d = embeddings_run_treq("Your text string goes here") | |
d.addCallback(lambda result: print(f"---{result}")) | |
d.addBoth(lambda _: reactor.stop()) | |
reactor.run() | |
if __name__ == "__main__": | |
main() |