summaryrefslogtreecommitdiffstats
path: root/docs/guides
diff options
context:
space:
mode:
Diffstat (limited to 'docs/guides')
-rw-r--r--docs/guides/create_provider.md62
-rw-r--r--docs/guides/help_me.md106
-rw-r--r--docs/guides/phone.jpegbin13405 -> 0 bytes
-rw-r--r--docs/guides/phone.md4
4 files changed, 170 insertions, 2 deletions
diff --git a/docs/guides/create_provider.md b/docs/guides/create_provider.md
new file mode 100644
index 00000000..e2e1ab6a
--- /dev/null
+++ b/docs/guides/create_provider.md
@@ -0,0 +1,62 @@
+#### Create Provider with AI Tool
+
+Call in your terminal the `create_provider` script:
+```bash
+python -m etc.tool.create_provider
+```
+1. Enter your name for the new provider.
+2. Copy and paste the `cURL` command from your browser developer tools.
+3. Let the AI ​​create the provider for you.
+4. Customize the provider according to your needs.
+
+#### Create Provider
+
+1. Check out the current [list of potential providers](https://github.com/zukixa/cool-ai-stuff#ai-chat-websites), or find your own provider source!
+2. Create a new file in [g4f/Provider](/g4f/Provider) with the name of the Provider
+3. Implement a class that extends [BaseProvider](/g4f/providers/base_provider.py).
+
+```py
+from __future__ import annotations
+
+from ..typing import AsyncResult, Messages
+from .base_provider import AsyncGeneratorProvider
+
+class HogeService(AsyncGeneratorProvider):
+ url = "https://chat-gpt.com"
+ working = True
+ supports_gpt_35_turbo = True
+
+ @classmethod
+ async def create_async_generator(
+ cls,
+ model: str,
+ messages: Messages,
+ proxy: str = None,
+ **kwargs
+ ) -> AsyncResult:
+ yield ""
+```
+
+4. Here, you can adjust the settings, for example, if the website does support streaming, set `supports_stream` to `True`...
+5. Write code to request the provider in `create_async_generator` and `yield` the response, _even if_ it's a one-time response, do not hesitate to look at other providers for inspiration
+6. Add the Provider Import in [`g4f/Provider/__init__.py`](./g4f/Provider/__init__.py)
+
+```py
+from .HogeService import HogeService
+
+__all__ = [
+ HogeService,
+]
+```
+
+7. You are done !, test the provider by calling it:
+
+```py
+import g4f
+
+response = g4f.ChatCompletion.create(model='gpt-3.5-turbo', provider=g4f.Provider.PROVIDERNAME,
+ messages=[{"role": "user", "content": "test"}], stream=g4f.Provider.PROVIDERNAME.supports_stream)
+
+for message in response:
+ print(message, flush=True, end='')
+``` \ No newline at end of file
diff --git a/docs/guides/help_me.md b/docs/guides/help_me.md
new file mode 100644
index 00000000..1a56a74a
--- /dev/null
+++ b/docs/guides/help_me.md
@@ -0,0 +1,106 @@
+### Guide: How can AI help me with writing code?
+
+πŸ€– Ever dreamt of writing code at lightning speed, effortlessly crafting clean, bug-free functionalities? Welcome to the age of AI-powered coding, where your imagination merges seamlessly with the machine's precision. This guide unveils 4 powerful ways AI can become your secret weapon in the coding world, saving you time, resources, and frustration. 😎
+
+- Language Agnostic? No Problem! Rewrite Code with Ease
+- Improving Written Code: Polish Your Code Like a Pro
+- Demystifying the Unreadable: Deobfuscating Unreadable Code
+- Custom Functions: Your AI-Powered Genie in a Bottle
+
+So you can streamline your coding process, improve code quality, and enhance productivity.
+
+#### 1. Rewriting Code from One Language to Another
+You can leverage AI to translate code from one programming language to another. For instance, you can easily convert JavaScript code to Python using the following approach:
+
+**Prompt:**
+```
+Rewrite this JavaScript code to Python code. Use the aiohttp package:
+```
+```javascript
+async function fetch_data(url) {
+ const response = await fetch(url);
+ const data = await response.json();
+ return data;
+}
+```
+
+**AI Response:**
+```python
+import aiohttp
+
+async def fetch_data(url):
+ async with aiohttp.ClientSession() as session:
+ async with session.get(url) as response:
+ data = await response.json()
+ return data
+```
+
+#### 2. Improving Written Code
+You can ask the AI to enhance your code by adding comments, docstrings, and type hints for better readability and maintainability.
+
+**Example Usage:**
+```
+Improve this Python code, add Google docstrings and type hints.
+Responses with the complete code and don't use placeholders.
+Keep the comments:
+```
+```python
+def calculate_area(radius):
+ # Calculate the area of a circle
+ return 3.14 * radius ** 2
+```
+
+**AI Response:**
+```python
+def calculate_area(radius: float) -> float:
+ """Calculate the area of a circle.
+
+ Args:
+ radius (float): The radius of the circle.
+
+ Returns:
+ float: The area of the circle.
+ """
+ return 3.14 * radius ** 2
+```
+
+#### 3. Deobfuscating Unreadable Code
+AI can help in making obfuscated or unreadable code more understandable and maintainable.
+
+**Example Usage:**
+```
+Deobfuscate this JavaScript code. Improve the readability:
+```
+
+```javascript
+(function() {
+ var a = 'Hello', b = 'World';
+ console.log(a + ' ' + b);
+})();
+```
+
+**AI Response:**
+```javascript
+(function() {
+ var greeting = 'Hello';
+ var subject = 'World';
+ console.log(greeting + ' ' + subject);
+})();
+```
+
+#### 4. Writing Custom Functions
+You can also ask the AI to generate custom functions or help you with specific coding issues.
+
+**Example Usage:**
+```
+Write a function that returns the sum of two numbers.
+```
+
+**AI Response:**
+```python
+def add_numbers(a, b):
+ """Add two numbers together."""
+ return a + b
+```
+
+These are just a few ways AI can revolutionize your coding experience. As AI technology continues to evolve, the possibilities are endless. So, embrace the future, unlock the power of AI, and watch your coding potential soar! πŸ‘·β€β™‚οΈ \ No newline at end of file
diff --git a/docs/guides/phone.jpeg b/docs/guides/phone.jpeg
deleted file mode 100644
index 0cc57b14..00000000
--- a/docs/guides/phone.jpeg
+++ /dev/null
Binary files differ
diff --git a/docs/guides/phone.md b/docs/guides/phone.md
index 2d3ec032..60a09e9d 100644
--- a/docs/guides/phone.md
+++ b/docs/guides/phone.md
@@ -21,9 +21,9 @@ Running Python applications on your smartphone is possible with specialized apps
- In the app settings for Pydroid, disable power-saving mode and ensure that the option to pause when not in use is also disabled. This ensures uninterrupted operation of your Python scripts.
4. **Install Required Packages:**
- - Open Pip within the Pydroid app and install the necessary packages by executing the following commands:
+ - Open Pip within the Pydroid app and install this necessary packages:
```
- pip install g4f flask pillow beautifulsoup4
+ g4f flask pillow beautifulsoup4
```
5. **Create a New Python Script:**