Accessing Microsoft Copilot programmatically
Hello, the below sample python code shows how to access chatgpt programmatically with a prompt. My question is - is it possible to do something equivalent programmatically with Microsoft copilot:
import openai
import os
from dotenv import load_dotenv, find_dotenv
__ = load_dotenv(find_dotenv())_
openai.api_key = os.getenv('OPENAI_API_KEY')
def get_completion(prompt, model="gpt-3.5-turbo"):
messages = [{"role": "user", "content": prompt}]
response = openai.ChatCompletion.create(
model=model,
messages=messages,
temperature=0, # this is the degree of randomness of the model's output
)
return response.choices[0].message["content"]
text_1 = f"""
_Making a cup of tea is easy! First, you need to get some _
_water boiling. While that's happening, _
_grab a cup and put a tea bag in it. Once the water is _
_hot enough, just pour it over the tea bag. _
_Let it sit for a bit so the tea can steep. After a _
_few minutes, take out the tea bag. If you _
_like, you can add some sugar or milk to taste. _
_And that's it! You've got yourself a delicious _
cup of tea to enjoy.
"""
prompt = f"""
You will be provided with text delimited by triple quotes.
_If it contains a sequence of instructions, _
re-write those instructions in the following format:
Step 1 - ...
Step 2 - …
…
Step N - …
_If the text does not contain a sequence of instructions, _
then simply write "No steps provided."
"""{text_1}"""
"""
response = get_completion(prompt)
print("Completion for Text 1:")
print(response)