import os from flask import Flask import threading API_URL = "https://api-inference.huggingface.co/models/sentence-transformers/all-MiniLM-L6-v2" bearer = "Bearer " + os.getenv('TOKEN') headers = {"Authorization": bearer } print("headers") print(headers) app = Flask(__name__) @app.route('/app') def server_app(): t1 = threading.Thread(target=threadserver) print('treading') # os.system('./mxbai-embed-large-v1-f16.llamafile --server --nobrowser') t1.start() return 't1.start()' @app.route('/') def server_home(): # t1 = threading.Thread(target=threadserver).start() # os.system(' ./mxbai-embed-large-v1-f16.llamafile --server --nobrowser &') return str(headers) # import asyncio # async def nested(): # return 42 # async def main(): # # Nothing happens if we just call "nested()". # # A coroutine object is created but not awaited, # # so it *won't run at all*. # nested() # will raise a "RuntimeWarning". # # Let's do it differently now and await it: # print(await nested()) # will print "42". # asyncio.run(main()) if __name__=='__main__': app.run(debug=True) def threadserver(): print('hi') os.system(' ./mxbai-embed-large-v1-f16.llamafile --server --nobrowser') # import requests # import os # import asyncio # # from langchain_core.tools import Tool # # from langchain_google_community import GoogleSearchAPIWrapper # from flask import Flask # API_URL = "https://api-inference.huggingface.co/models/sentence-transformers/all-MiniLM-L6-v2" # bearer = "Bearer " + os.getenv('TOKEN') # headers = {"Authorization": bearer } # print("headers") # print(headers) # app = Flask(__name__) # async def command_similarity(): # payload = {"inputs": {"source_sentence": "That is a happy person","sentences": ["That is a happy dog","That is a very happy person","Today is a sunny day"]},} # return str( requests.post(API_URL, headers=headers, json=payload) ) # async def asynm1(): # return await command_similarity() # @app.route('/app') # def server_home(): # asyncio.run(asynm1()) # print("command run") # return asyncio.run(asynm1()) # import asyncio # async def nested(): # return 42 # async def main(): # # Nothing happens if we just call "nested()". # # A coroutine object is created but not awaited, # # so it *won't run at all*. # nested() # will raise a "RuntimeWarning". # # Let's do it differently now and await it: # print(await nested()) # will print "42". # asyncio.run(main())