Spaces:
Running
Running
File size: 752 Bytes
e397647 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
from twisted.internet import reactor, defer
from treq import post
import json
@defer.inlineCallbacks
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() |