For more detailed instructions you may follow the steps here https://learn.unity.com/tutorial/vr-project-setup#65c511fbedbc2a263ed98728.
Instructions for connecting to ChatGPT: Make sure you have an OpenAI account.
After creating an account go to https://platform.openai.com/account/api-keys to create an API key.
To make requests to the OpenAI API, you need to use your API key and organization name (if applicable). To avoid exposing your API key in your Unity project, you can save it in your device's local storage.
To do this, follow these steps:
Create a folder called .openai in your home directory (e.g. C:User\UserName\ for Windows or ~\ for Linux or Mac) Create a file called auth.json in the .openai folder Add an api_key field and a organization field (if applicable) to the auth.json file and save it Here is an example of what your auth.json file should look like: { "api_key": "sk-...W6yi", "organization": "org-...L7W" }
For more information you can visit this repository https://github.com/srcnalt/OpenAI-Unity?tab=readme-ov-file
-Class and Event Definition
ChatGPTManager: This is the main class that manages interactions with the OpenAI API.
OnResponseEvent: A custom Unity event that takes a single string parameter. It's used to trigger actions when a response from the chat model is received. Fields
OnResponse: An instance of OnResponseEvent which other components can subscribe to in order to react when the chat model produces a response.
openAI: An instance of OpenAIApi, which is presumably a class responsible for handling API requests to OpenAI.
messages: A list of ChatMessage objects, representing the conversation history. ChatMessage seems to be a custom class which isn't defined here but likely stores message content and the role of the message sender (user or AI).
-Methods
AskChatGPT(string newText): This method is called to send a new text message to the chat model. It first creates a new ChatMessage for the user's input and adds it to the messages list. A new CreateChatCompletionRequest object is constructed with the current conversation history. This request is then sent to the chat model specified (gpt-4). The response from the API is checked to ensure it contains valid data. The first response message is then added to the conversation history and logged in the Unity console. The content of the response is also passed to any subscribers of the OnResponse event.
Start(): A Unity lifecycle method called before the first frame update. It's empty here, indicating no initialization behavior is needed at the start.
Update(): Another Unity lifecycle method called once per frame. It's also empty, indicating no per-frame behavior is necessary.
-Key Aspects of the Code
Asynchronous Communication: The AskChatGPT method is asynchronous (marked with async), which allows the Unity application to remain responsive while waiting for the network response from OpenAI's servers.
Event Handling: The use of UnityEvent allows other parts of the Unity application to react to chat responses without tightly coupling components, following an event-driven architecture.
Debugging and Feedback: The Debug.Log call in AskChatGPT helps in logging the response for debugging purposes.
To set up the website for the Holos project, follow these steps:
cd holos1website
npm install
npm run dev
This will start the website on your local machine at http://localhost:3000.
npm run build
This will create a production-ready build of the website in the build folder.
Deploy the website: To deploy the website, you can use any hosting platform of your choice. For example, you can use Vercel or Netlify to deploy the website. Please refer to their documentation for specific instructions.
Here is our website https://holos1med.com/
To integrate AWS API with your project, follow these steps:
Set up AWS credentials: Ensure you have an AWS account and have access to the AWS Management Console. Create an IAM user with appropriate permissions and generate access keys (Access Key ID and Secret Access Key).
Configure your environment:
Store your AWS credentials securely in your environment variables or use AWS SDKs to configure them programmatically. For example, you can set them in your .env file:
AWS_ACCESS_KEY_ID=your_access_key_id
AWS_SECRET_ACCESS_KEY=your_secret_access_key
npm install aws-sdk
const AWS = require('aws-sdk');
AWS.config.update({region: 'us-east-1'});
const lambda = new AWS.Lambda();
lambda.invoke({FunctionName: 'your_lambda_function_name', Payload: JSON.stringify({key: 'value'})}, (error, data) => {
if (error) {
console.error(error);
} else {
console.log(data);
}
});
These steps will help you connect and interact with AWS APIs from your project, enabling you to leverage the vast array of services provided by AWS.
C#
97.6%
ShaderLab
1.2%
For more detailed instructions you may follow the steps here https://learn.unity.com/tutorial/vr-project-setup#65c511fbedbc2a263ed98728.
Instructions for connecting to ChatGPT: Make sure you have an OpenAI account.
After creating an account go to https://platform.openai.com/account/api-keys to create an API key.
To make requests to the OpenAI API, you need to use your API key and organization name (if applicable). To avoid exposing your API key in your Unity project, you can save it in your device's local storage.
To do this, follow these steps:
Create a folder called .openai in your home directory (e.g. C:User\UserName\ for Windows or ~\ for Linux or Mac) Create a file called auth.json in the .openai folder Add an api_key field and a organization field (if applicable) to the auth.json file and save it Here is an example of what your auth.json file should look like: { "api_key": "sk-...W6yi", "organization": "org-...L7W" }
For more information you can visit this repository https://github.com/srcnalt/OpenAI-Unity?tab=readme-ov-file
-Class and Event Definition
ChatGPTManager: This is the main class that manages interactions with the OpenAI API.
OnResponseEvent: A custom Unity event that takes a single string parameter. It's used to trigger actions when a response from the chat model is received. Fields
OnResponse: An instance of OnResponseEvent which other components can subscribe to in order to react when the chat model produces a response.
openAI: An instance of OpenAIApi, which is presumably a class responsible for handling API requests to OpenAI.
messages: A list of ChatMessage objects, representing the conversation history. ChatMessage seems to be a custom class which isn't defined here but likely stores message content and the role of the message sender (user or AI).
-Methods
AskChatGPT(string newText): This method is called to send a new text message to the chat model. It first creates a new ChatMessage for the user's input and adds it to the messages list. A new CreateChatCompletionRequest object is constructed with the current conversation history. This request is then sent to the chat model specified (gpt-4). The response from the API is checked to ensure it contains valid data. The first response message is then added to the conversation history and logged in the Unity console. The content of the response is also passed to any subscribers of the OnResponse event.
Start(): A Unity lifecycle method called before the first frame update. It's empty here, indicating no initialization behavior is needed at the start.
Update(): Another Unity lifecycle method called once per frame. It's also empty, indicating no per-frame behavior is necessary.
-Key Aspects of the Code
Asynchronous Communication: The AskChatGPT method is asynchronous (marked with async), which allows the Unity application to remain responsive while waiting for the network response from OpenAI's servers.
Event Handling: The use of UnityEvent allows other parts of the Unity application to react to chat responses without tightly coupling components, following an event-driven architecture.
Debugging and Feedback: The Debug.Log call in AskChatGPT helps in logging the response for debugging purposes.
To set up the website for the Holos project, follow these steps:
cd holos1website
npm install
npm run dev
This will start the website on your local machine at http://localhost:3000.
npm run build
This will create a production-ready build of the website in the build folder.
Deploy the website: To deploy the website, you can use any hosting platform of your choice. For example, you can use Vercel or Netlify to deploy the website. Please refer to their documentation for specific instructions.
Here is our website https://holos1med.com/
To integrate AWS API with your project, follow these steps:
Set up AWS credentials: Ensure you have an AWS account and have access to the AWS Management Console. Create an IAM user with appropriate permissions and generate access keys (Access Key ID and Secret Access Key).
Configure your environment:
Store your AWS credentials securely in your environment variables or use AWS SDKs to configure them programmatically. For example, you can set them in your .env file:
AWS_ACCESS_KEY_ID=your_access_key_id
AWS_SECRET_ACCESS_KEY=your_secret_access_key
npm install aws-sdk
const AWS = require('aws-sdk');
AWS.config.update({region: 'us-east-1'});
const lambda = new AWS.Lambda();
lambda.invoke({FunctionName: 'your_lambda_function_name', Payload: JSON.stringify({key: 'value'})}, (error, data) => {
if (error) {
console.error(error);
} else {
console.log(data);
}
});
These steps will help you connect and interact with AWS APIs from your project, enabling you to leverage the vast array of services provided by AWS.
C#
97.6%
ShaderLab
1.2%