elucidator8918 commited on
Commit
49bd08e
·
verified ·
1 Parent(s): 0e4d72d

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +38 -2
README.md CHANGED
@@ -55,10 +55,46 @@ from transformers import pipeline
55
 
56
  api_gen_pipeline = pipeline("text-generation", model="elucidator8918/apigen-prototype-0.1")
57
 
58
- generated_api_code = api_gen_pipeline("Your prompt or input text here", max_length=150, num_return_sequences=1)
59
- print(generated_api_code)
 
 
 
60
  ```
61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  ## License
63
 
64
  This model is released under the MIT License.
 
55
 
56
  api_gen_pipeline = pipeline("text-generation", model="elucidator8918/apigen-prototype-0.1")
57
 
58
+ # Run text generation pipeline with our next model
59
+ prompt = "Write code to do a POST request in FastAPI framework to find the multiplication of two matrices using NumPy"
60
+ pipe = pipeline(task="text-generation", model=model, tokenizer=tokenizer, max_length=500)
61
+ result = pipe(f"[INST] {prompt} [/INST]")
62
+ print(result[0]['generated_text'])
63
  ```
64
 
65
+ - **Output API Generation:**
66
+ ```
67
+ [INST] Write code to do a POST request in fastapi framework to find the multiplication of two matrices using numpy [/INST]
68
+ Below is an example of how to make a POST request in FastAPI to find the multiplication of two matrices using numpy:
69
+ ```
70
+ ```python
71
+ from fastapi import FastAPI, HTTPException
72
+ import numpy as np
73
+
74
+ app = FastAPI()
75
+
76
+ @app.post("/matrix_multiplication")
77
+ async def matrix_multiplication(matrix1: np.ndarray, matrix2: np.ndarray):
78
+ if matrix1.shape[1]!= matrix2.shape[0]:
79
+ raise HTTPException(status_code=400, detail="The number of columns in matrix1 must be equal to the number of rows in matrix2")
80
+ result = np.matmul(matrix1, matrix2)
81
+ return {"result": result}
82
+ ```
83
+ This code defines a FastAPI endpoint at `/matrix_multiplication` that takes two matrices as input and returns the multiplication of the two matrices. The `np.matmul` function is used to perform the multiplication. The endpoint also includes a check to ensure that the number of columns in the first matrix is equal to the number of rows in the second matrix.
84
+
85
+ To use this endpoint, you can make a POST request to `http://localhost:8000/matrix_multiplication` with the two matrices as input. The response will include the multiplication of the two matrices.
86
+ ```python
87
+ import requests
88
+
89
+ matrix1 = np.array([[1, 2], [3, 4]])
90
+ matrix2 = np.array([[5, 6], [7, 8]])
91
+
92
+ response = requests.post("http://localhost:8000/matrix_multiplication", json={"matrix1": matrix1, "matrix2": matrix2})
93
+
94
+ print(response.json())
95
+ ```
96
+ This code makes a POST request to the endpoint with the two matrices as input and prints the response. The response should include the multiplication of the two matrices, which is `[[11, 14], [29, 36]]`.
97
+
98
  ## License
99
 
100
  This model is released under the MIT License.