Spaces:
Runtime error
Runtime error
hoollyzhang
commited on
Commit
·
742add2
1
Parent(s):
fbbb23b
feat:Add application file
Browse files
README.md
CHANGED
|
@@ -1,145 +1,8 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
- Dataset Analysis, Stock Charting, Image Manipulation, ....
|
| 11 |
-
- Internet access and auto Python package installation
|
| 12 |
-
- Input `text + files` -> Receive `text + files`
|
| 13 |
-
- Conversation Memory: respond based on previous inputs
|
| 14 |
-
- Run everything local except the OpenAI API (OpenOrca or others maybe soon)
|
| 15 |
-
- Use CodeBox API for easy scaling in production (coming soon)
|
| 16 |
-
|
| 17 |
-
## Installation
|
| 18 |
-
|
| 19 |
-
Get your OpenAI API Key [here](https://platform.openai.com/account/api-keys) and install the package.
|
| 20 |
-
|
| 21 |
-
```bash
|
| 22 |
-
pip install codeinterpreterapi
|
| 23 |
-
```
|
| 24 |
-
|
| 25 |
-
## Usage
|
| 26 |
-
|
| 27 |
-
Make sure to set the `OPENAI_API_KEY` environment variable (or use a `.env` file)
|
| 28 |
-
|
| 29 |
-
```python
|
| 30 |
-
from codeinterpreterapi import CodeInterpreterSession
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
async def main():
|
| 34 |
-
# create a session
|
| 35 |
-
session = CodeInterpreterSession()
|
| 36 |
-
await session.astart()
|
| 37 |
-
|
| 38 |
-
# generate a response based on user input
|
| 39 |
-
response = await session.generate_response(
|
| 40 |
-
"Plot the bitcoin chart of 2023 YTD"
|
| 41 |
-
)
|
| 42 |
-
|
| 43 |
-
# output the response (text + image)
|
| 44 |
-
print("AI: ", response.content)
|
| 45 |
-
for file in response.files:
|
| 46 |
-
file.show_image()
|
| 47 |
-
|
| 48 |
-
# terminate the session
|
| 49 |
-
await session.astop()
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
if __name__ == "__main__":
|
| 53 |
-
import asyncio
|
| 54 |
-
# run the async function
|
| 55 |
-
asyncio.run(main())
|
| 56 |
-
|
| 57 |
-
```
|
| 58 |
-
|
| 59 |
-

|
| 60 |
-
Bitcoin YTD Chart Output
|
| 61 |
-
|
| 62 |
-
## Dataset Analysis
|
| 63 |
-
|
| 64 |
-
```python
|
| 65 |
-
from codeinterpreterapi import CodeInterpreterSession, File
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
async def main():
|
| 69 |
-
# context manager for auto start/stop of the session
|
| 70 |
-
async with CodeInterpreterSession() as session:
|
| 71 |
-
# define the user request
|
| 72 |
-
user_request = "Analyze this dataset and plot something interesting about it."
|
| 73 |
-
files = [
|
| 74 |
-
File.from_path("examples/assets/iris.csv"),
|
| 75 |
-
]
|
| 76 |
-
|
| 77 |
-
# generate the response
|
| 78 |
-
response = await session.generate_response(
|
| 79 |
-
user_request, files=files
|
| 80 |
-
)
|
| 81 |
-
|
| 82 |
-
# output to the user
|
| 83 |
-
print("AI: ", response.content)
|
| 84 |
-
for file in response.files:
|
| 85 |
-
file.show_image()
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
if __name__ == "__main__":
|
| 89 |
-
import asyncio
|
| 90 |
-
|
| 91 |
-
asyncio.run(main())
|
| 92 |
-
```
|
| 93 |
-
|
| 94 |
-

|
| 95 |
-
Iris Dataset Analysis Output
|
| 96 |
-
|
| 97 |
-
## Production
|
| 98 |
-
|
| 99 |
-
In case you want to deploy to production, you can utilize the CodeBox API for seamless scalability.
|
| 100 |
-
|
| 101 |
-
Please contact me if you are interested in this, as it is still in the early stages of development.
|
| 102 |
-
|
| 103 |
-
## Contributing
|
| 104 |
-
|
| 105 |
-
There are some remaining TODOs in the code.
|
| 106 |
-
So, if you want to contribute, feel free to do so.
|
| 107 |
-
You can also suggest new features. Code refactoring is also welcome.
|
| 108 |
-
Just open an issue or pull request and I will review it.
|
| 109 |
-
|
| 110 |
-
Please also submit any bugs you find as an issue with a minimal code example or screenshot.
|
| 111 |
-
This helps me a lot in improving the code.
|
| 112 |
-
|
| 113 |
-
Thanks!
|
| 114 |
-
|
| 115 |
-
## Streamlit WebApp
|
| 116 |
-
|
| 117 |
-
To start the web application created with streamlit:
|
| 118 |
-
|
| 119 |
-
```bash
|
| 120 |
-
streamlit run frontend/app.py
|
| 121 |
-
```
|
| 122 |
-
|
| 123 |
-
## License
|
| 124 |
-
|
| 125 |
-
[MIT](https://choosealicense.com/licenses/mit/)
|
| 126 |
-
|
| 127 |
-
## Contact
|
| 128 |
-
|
| 129 |
-
You can contact me at [contact@shroominic.com](mailto:contact@shroominic.com).
|
| 130 |
-
But I prefer to use [Twitter](https://twitter.com/shroominic) or [Discord](https://gptassistant.app/community) DMs.
|
| 131 |
-
|
| 132 |
-
## Support this project
|
| 133 |
-
|
| 134 |
-
If you would like to help this project with a donation, you can [click here](https://ko-fi.com/shroominic).
|
| 135 |
-
Thanks, this helps a lot! ❤️
|
| 136 |
-
|
| 137 |
-
## Star History
|
| 138 |
-
|
| 139 |
-
<a href="https://star-history.com/#shroominic/codeinterpreter-api&Date">
|
| 140 |
-
<picture>
|
| 141 |
-
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=shroominic/codeinterpreter-api&type=Date&theme=dark" />
|
| 142 |
-
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=shroominic/codeinterpreter-api&type=Date" />
|
| 143 |
-
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=shroominic/codeinterpreter-api&type=Date" />
|
| 144 |
-
</picture>
|
| 145 |
-
</a>
|
|
|
|
| 1 |
+
title: Codeinterpreter
|
| 2 |
+
emoji: 🦀
|
| 3 |
+
colorFrom: red
|
| 4 |
+
colorTo: red
|
| 5 |
+
sdk: streamlit
|
| 6 |
+
sdk_version: 1.21.0
|
| 7 |
+
app_file: app.py
|
| 8 |
+
pinned: false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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