diff --git a/docker-compose.yaml b/docker-compose.yaml index f4b30fa..0ed9d41 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -3,6 +3,8 @@ version: "3.9" services: frontend: build: ./frontend + environment: + - API_HOST=http://backend:5001 ports: - "5173:5173" diff --git a/frontend/src/conversation/conversationApi.ts b/frontend/src/conversation/conversationApi.ts index f1d42fa..e48d836 100644 --- a/frontend/src/conversation/conversationApi.ts +++ b/frontend/src/conversation/conversationApi.ts @@ -23,7 +23,9 @@ export function fetchAnswerApi( selectedDocs.model + '/'; - return fetch('https://docsapi.arc53.com/api/answer', { + const apiHost = import.meta.env.VITE_API_HOST || 'https://docsapi.arc53.com'; + + return fetch(apiHost + '/api/answer', { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/frontend/src/preferences/preferenceApi.ts b/frontend/src/preferences/preferenceApi.ts index 8b948c5..d4d5979 100644 --- a/frontend/src/preferences/preferenceApi.ts +++ b/frontend/src/preferences/preferenceApi.ts @@ -63,7 +63,8 @@ export function setLocalRecentDocs(doc: Doc): void { '/' + doc.model + '/'; - fetch('https://docsapi.arc53.com/api/docs_check', { + const apiHost = import.meta.env.VITE_API_HOST || 'https://docsapi.arc53.com'; + fetch(apiHost + '/api/docs_check', { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/scripts/outputs/test.md b/scripts/outputs/test.md deleted file mode 100644 index 7c1c419..0000000 --- a/scripts/outputs/test.md +++ /dev/null @@ -1,167 +0,0 @@ -# Function name: get_functions_in_class - -Function: -``` -def get_functions_in_class(source_code, class_name): - tree = ast.parse(source_code) - functions = [] - for node in tree.body: - if isinstance(node, ast.ClassDef): - if node.name == class_name: - for function in node.body: - if isinstance(function, ast.FunctionDef): - functions.append(function.name) - return functions -```, -Documentation: - - -get_functions_in_class(source_code, class_name) - -Inputs: -source_code (str): The source code of the program. -class_name (str): The name of the class. - -Outputs: -functions (list): A list of the functions in the class. - -Description: -This function takes in a source code and a class name and returns a list of the functions in the class. It uses the ast module to parse the source code and find the class definition. It then iterates through the body of the class and checks if each node is a function definition. If it is, it adds the name of the function to the list of functions. - -# Function name: process_functions - -Function: -``` -def process_functions(functions_dict): - c1 = len(functions_dict) - c2 = 0 - for (source, functions) in functions_dict.items(): - c2 += 1 - print(f'Processing file {c2}/{c1}') - f1 = len(functions) - f2 = 0 - source_w = source.replace('inputs/', '') - source_w = source_w.replace('.py', '.md') - create_subfolder(source_w) - for (name, function) in functions.items(): - f2 += 1 - print(f'Processing function {f2}/{f1}') - response = generate_response(function) - write_output_file(source_w, name, function, response) -```, -Documentation: - - -This function takes in a dictionary of functions and processes them. It takes the source file and the functions from the dictionary and creates a subfolder for the source file. It then generates a response for each function and writes the output file. The output file contains the function, the response, and the source file. - -# Function name: get_functions_in_class - -Function: -``` -def get_functions_in_class(source_code, class_name): - tree = ast.parse(source_code) - functions = [] - for node in tree.body: - if isinstance(node, ast.ClassDef): - if node.name == class_name: - for function in node.body: - if isinstance(function, ast.FunctionDef): - functions.append(function.name) - return functions -```, -Documentation: - - -get_functions_in_class(source_code, class_name) - -Inputs: -source_code (str): The source code of the program. -class_name (str): The name of the class. - -Outputs: -functions (list): A list of the functions in the class. - -Description: -This function takes in a source code and a class name and returns a list of the functions in the class. It uses the ast module to parse the source code and find the class definition. It then iterates through the body of the class and checks if each node is a function definition. If it is, it adds the name of the function to the list of functions. - -# Function name: process_functions - -Function: -``` -def process_functions(functions_dict): - c1 = len(functions_dict) - c2 = 0 - for (source, functions) in functions_dict.items(): - c2 += 1 - print(f'Processing file {c2}/{c1}') - f1 = len(functions) - f2 = 0 - source_w = source.replace('inputs/', '') - source_w = source_w.replace('.py', '.md') - create_subfolder(source_w) - for (name, function) in functions.items(): - f2 += 1 - print(f'Processing function {f2}/{f1}') - response = generate_response(function) - write_output_file(source_w, name, function, response) -```, -Documentation: - - -This function takes in a dictionary of functions and processes them. It takes the source file and the functions from the dictionary and creates a subfolder for the source file. It then generates a response for each function and writes the output file for each function. - -# Function name: get_functions_in_class - -Function: -``` -def get_functions_in_class(source_code, class_name): - tree = ast.parse(source_code) - functions = [] - for node in tree.body: - if isinstance(node, ast.ClassDef): - if node.name == class_name: - for function in node.body: - if isinstance(function, ast.FunctionDef): - functions.append(function.name) - return functions -```, -Documentation: - - -get_functions_in_class(source_code, class_name) - -Inputs: -source_code (str): The source code of the program. -class_name (str): The name of the class. - -Outputs: -functions (list): A list of the functions in the class. - -Description: -This function takes in a source code and a class name and returns a list of the functions in the class. It uses the ast module to parse the source code and find the class definition. It then iterates through the body of the class and checks if each node is a function definition. If it is, it adds the name of the function to the list of functions. - -# Function name: process_functions - -Function: -``` -def process_functions(functions_dict): - c1 = len(functions_dict) - c2 = 0 - for (source, functions) in functions_dict.items(): - c2 += 1 - print(f'Processing file {c2}/{c1}') - f1 = len(functions) - f2 = 0 - source_w = source.replace('inputs/', '') - source_w = source_w.replace('.py', '.md') - create_subfolder(source_w) - for (name, function) in functions.items(): - f2 += 1 - print(f'Processing function {f2}/{f1}') - response = generate_response(function) - write_output_file(source_w, name, function, response) -```, -Documentation: - - -This function takes in a dictionary of functions and processes them. It takes the source file and the functions from the dictionary and creates a subfolder for the source file. It then generates a response for each function and writes the output file for each function. \ No newline at end of file